Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define cls system("cls")
- #define pause system("pause")
- #define TOPTEN 10
- typedef struct
- {
- char initials[4];
- int score;
- }SCORELIST;
- int mainMenu(void);
- int main(void) {
- int i = 0;
- int pass ;
- int score ;
- score = 60;
- SCORELIST player[500];
- player[0].score = 56;
- player[1].score = 16;
- player[2].score = 23;
- player[3].score = 30;
- player[4].score = 27;
- player[5].score = 17;
- player[6].score = 18;
- player[7].score = 22;
- player[8].score = 34;
- player[9].score = 15;
- SCORELIST temp;
- strcpy(player[0].initials, "DSM");
- strcpy(player[1].initials, "ADA");
- strcpy(player[2].initials, "AxS");
- strcpy(player[3].initials, "TWT");
- strcpy(player[4].initials, "DBK");
- strcpy(player[5].initials, "MUM");
- strcpy(player[6].initials, "YAY");
- strcpy(player[7].initials, "POP");
- strcpy(player[8].initials, "PEP");
- strcpy(player[9].initials, "CUR");
- for (pass = 1; pass <= TOPTEN - 1; pass++) {
- for ( i = 0; i <TOPTEN - 1; i++) {
- if (player[i].score > player[i+1].score) {
- temp = player[i];
- player[i]= player[i+1];
- player[i+1] = temp;
- }
- }
- }
- printf("\n HIGH SCORES \n");
- printf(" =======================\n");
- printf("\tNAME\t\tSCORE\n");
- printf("\t=====\t\t======\n");
- for (i = 0; i < TOPTEN; i++) {
- printf("\t%3s\t\t\t%2i\n",player[i].initials,player[i].score);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement