Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <string.h>
- #define SIZE 30
- typedef struct {
- int id;
- int help;
- char name[SIZE];
- char *task;
- }student;
- void swap(int *xp, int *yp)
- {
- int temp = *xp;
- *xp = *yp;
- *yp = temp;
- }
- void bubbleSort(int arr[], int n)
- {
- int i, j;
- for (i = 0; i < n-1; i++)
- // Last i elements are already in place
- for (j = 0; j < n-i-1; j++)
- if (arr[j] > arr[j+1])
- swap(&arr[j], &arr[j+1]);
- }
- int main(void)
- {
- int i;
- int noSessions;
- int noStudents;
- printf("Enter number of consultation sesssions: ");
- scanf("%d",&noSessions);
- printf("Enter number of students: ");
- scanf("%d",&noStudents);
- student arr[noStudents];
- for(i = 0; i < noStudents; i++){
- int j = i + 1;
- printf("Enter enter student %d ID, name and consultation session.", j);
- scanf("%d" "%s" "%d", &arr[i].id, &arr[i].name, &arr[i].help);
- }
- printf("Student ID == Full Name == Consultation Session");
- for(i = 0; i < noStudents; i++){
- printf("\n");
- printf("%d <> %s <> %d", arr[i].id, arr[i].name, arr[i].help);
- printf("\n");
- }
- bubbleSort(arr, noStudents);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement