Compare commits
No commits in common. "1ccf575914356a1f8c3ef6d000ca56fa033831b9" and "2bf622768476b7ce2c52942f5416e4795fbb0e24" have entirely different histories.
1ccf575914
...
2bf6227684
@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define MAX_SIZE 4
|
#define MAX_SIZE 5
|
||||||
|
|
||||||
int queue[MAX_SIZE];
|
int queue[MAX_SIZE];
|
||||||
int front = 0;
|
int front = 0;
|
||||||
@ -8,7 +8,7 @@ int rear = 0;
|
|||||||
|
|
||||||
void enqueue(int data) {
|
void enqueue(int data) {
|
||||||
if ((rear + 1) % MAX_SIZE == front) {
|
if ((rear + 1) % MAX_SIZE == front) {
|
||||||
printf("\n\nQueue is full\n\n\n");
|
printf("Queue is full\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
queue[rear] = data;
|
queue[rear] = data;
|
||||||
@ -41,12 +41,11 @@ void printQueue() {
|
|||||||
int main() {
|
int main() {
|
||||||
int choice, data;
|
int choice, data;
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("Choose the Circular Queue option you would like to perform:\n");
|
|
||||||
printf("1. Enqueue\n2. Dequeue\n3. Print Queue\n4. Exit\n");
|
printf("1. Enqueue\n2. Dequeue\n3. Print Queue\n4. Exit\n");
|
||||||
scanf("%d", &choice);
|
scanf("%d", &choice);
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 1:
|
case 1:
|
||||||
printf("Enter the value for the latest element: ");
|
printf("Enter data: ");
|
||||||
scanf("%d", &data);
|
scanf("%d", &data);
|
||||||
enqueue(data);
|
enqueue(data);
|
||||||
break;
|
break;
|
||||||
@ -59,9 +58,6 @@ int main() {
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
|
||||||
printf("Invalid choice.");
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,19 +31,10 @@ int main() {
|
|||||||
struct Element b[MAX_TERMS];
|
struct Element b[MAX_TERMS];
|
||||||
int m = 4, n = 3, num = 4;
|
int m = 4, n = 3, num = 4;
|
||||||
|
|
||||||
printf("The Original Matrix is:\n\n");
|
|
||||||
printf("row col val\n");
|
|
||||||
for (int i = 0; i < num; i++)
|
|
||||||
printf("%d\t%d\t%d\n", a[i].row, a[i].col, a[i].value);
|
|
||||||
|
|
||||||
printf("\n\n");
|
|
||||||
fastTranspose(a, b, m, n, num);
|
fastTranspose(a, b, m, n, num);
|
||||||
|
|
||||||
printf("The Transpose Matrix is:\n\n");
|
|
||||||
printf("row col val\n");
|
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
printf("%d\t%d\t%d\n", b[i].row, b[i].col, b[i].value);
|
printf("%d %d %d\n", b[i].row, b[i].col, b[i].value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,37 @@
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.lang.Math;
|
||||||
|
|
||||||
class Armstrong {
|
class Armstrong{
|
||||||
|
public static void main(String args[]){
|
||||||
public static void main(String[] args) {
|
|
||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
|
|
||||||
System.out.println("Enter a number");
|
int a,b,digit;
|
||||||
|
int digisum=0;
|
||||||
|
int c=0;
|
||||||
|
|
||||||
int n = sc.nextInt();
|
System.out.println("Enter the number you went to check for Armstrong-ness:");
|
||||||
int b = String.valueOf(n).length();
|
a = sc.nextInt();
|
||||||
int sum = 0;
|
|
||||||
int temp = n;
|
b = a;
|
||||||
while (temp > 0) {
|
|
||||||
int r = temp % 10;
|
while(b!=0){
|
||||||
sum += Math.pow(r, b);
|
c++;
|
||||||
temp /= 10;
|
b/=10;
|
||||||
}
|
}
|
||||||
if (sum == n) {
|
|
||||||
System.out.println("The given number is an Armstrong Number.");
|
b = a;
|
||||||
} else {
|
|
||||||
System.out.println("The given number is not an Armstrong Number.");
|
while(b!=0){
|
||||||
|
digit = b%10;
|
||||||
|
digisum += Math.pow(digit, c);
|
||||||
|
b /= 10;
|
||||||
}
|
}
|
||||||
sc.close();
|
|
||||||
|
if(digisum == a){
|
||||||
|
System.out.println("The number is an armstrong number.");
|
||||||
|
}else{
|
||||||
|
System.out.println("The number is not an armstrong number.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user