Advertisement
Guest User

Untitled

a guest
Apr 26th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // #include "stdafx.h" crap not needed
  2. #include <stdio.h>
  3. #include <string.h>
  4. // #include <conio.h> crap not needed
  5. #include <stdlib.h>
  6.  
  7.  
  8. #define NO_OF_STUDENTS 4 // too lazy for 20
  9.  
  10. struct data {
  11. char name[20];
  12. int age;
  13. int weight;
  14. };
  15.  
  16. int main()
  17. {
  18. struct data Students[NO_OF_STUDENTS]; // 20 students.
  19. int Counter = 0;
  20.  
  21. for (Counter = 0; Counter < NO_OF_STUDENTS; ++Counter) {
  22. scanf("%s", Students[Counter].name);
  23. scanf("%d", &Students[Counter].age);
  24. scanf("%d", &Students[Counter].weight);
  25. }
  26.  
  27. for (Counter = 0; Counter < NO_OF_STUDENTS; ++Counter) {
  28. printf("Name=%s, ", Students[Counter].name);
  29. printf("Age=%d, ", Students[Counter].age);
  30. printf("Weight=%d\n", Students[Counter].weight);
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. qsort(Students,4,sizeof(int),compare);
  42.  
  43. for (Counter = 0; Counter < NO_OF_STUDENTS; ++Counter) {
  44. printf("Name=%s, ", Students[Counter].name);
  45. printf("Age=%d, ", Students[Counter].age);
  46. printf("Weight=%d\n", Students[Counter].weight);
  47. }
  48.  
  49. if(strcmp(Students,NO_OF_STUDENTS)){
  50.  
  51. printf("Name=%s, ", Students[Counter].name);
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58. return 0;
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement