Merge pull request 'lab_branch' (#1) from lab_branch into main

Reviewed-on: #1
This commit is contained in:
Aadit Agrawal 2024-08-31 01:22:43 +05:30
commit 1ccf575914
3 changed files with 43 additions and 41 deletions

View file

@ -1,6 +1,6 @@
#include <stdio.h>
#define MAX_SIZE 5
#define MAX_SIZE 4
int queue[MAX_SIZE];
int front = 0;
@ -8,7 +8,7 @@ int rear = 0;
void enqueue(int data) {
if ((rear + 1) % MAX_SIZE == front) {
printf("Queue is full\n");
printf("\n\nQueue is full\n\n\n");
return;
}
queue[rear] = data;
@ -41,11 +41,12 @@ void printQueue() {
int main() {
int choice, data;
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");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Enter data: ");
printf("Enter the value for the latest element: ");
scanf("%d", &data);
enqueue(data);
break;
@ -58,6 +59,9 @@ int main() {
break;
case 4:
return 0;
default:
printf("Invalid choice.");
return -1;
}
}
}

View file

@ -31,10 +31,19 @@ int main() {
struct Element b[MAX_TERMS];
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);
printf("The Transpose Matrix is:\n\n");
printf("row col val\n");
for (int i = 0; i < num; i++)
printf("%d %d %d\n", b[i].row, b[i].col, b[i].value);
printf("%d\t%d\t%d\n", b[i].row, b[i].col, b[i].value);
return 0;
}