Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #define cls system("cls")
  6. #define pause system("pause")
  7.  
  8. #define TOPTEN 10
  9.  
  10.  
  11. typedef struct
  12. {
  13. char initials[4];
  14. int score;
  15. }SCORELIST;
  16. int mainMenu(void);
  17.  
  18. int main(void) {
  19. int i = 0;
  20. int pass ;
  21. int score ;
  22. score = 60;
  23. SCORELIST player[500];
  24. player[0].score = 56;
  25. player[1].score = 16;
  26. player[2].score = 23;
  27. player[3].score = 30;
  28. player[4].score = 27;
  29. player[5].score = 17;
  30. player[6].score = 18;
  31. player[7].score = 22;
  32. player[8].score = 34;
  33. player[9].score = 15;
  34. SCORELIST temp;
  35. strcpy(player[0].initials, "DSM");
  36. strcpy(player[1].initials, "ADA");
  37. strcpy(player[2].initials, "AxS");
  38. strcpy(player[3].initials, "TWT");
  39. strcpy(player[4].initials, "DBK");
  40. strcpy(player[5].initials, "MUM");
  41. strcpy(player[6].initials, "YAY");
  42. strcpy(player[7].initials, "POP");
  43. strcpy(player[8].initials, "PEP");
  44. strcpy(player[9].initials, "CUR");
  45. for (pass = 1; pass <= TOPTEN - 1; pass++) {
  46. for ( i = 0; i <TOPTEN - 1; i++) {
  47. if (player[i].score > player[i+1].score) {
  48. temp = player[i];
  49. player[i]= player[i+1];
  50. player[i+1] = temp;
  51. }
  52. }
  53. }
  54.  
  55. printf("\n HIGH SCORES \n");
  56. printf(" =======================\n");
  57. printf("\tNAME\t\tSCORE\n");
  58. printf("\t=====\t\t======\n");
  59. for (i = 0; i < TOPTEN; i++) {
  60. printf("\t%3s\t\t\t%2i\n",player[i].initials,player[i].score);
  61. }
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement