個人相片
help!學期總成績bug!!
100資專0310 林宣含發表於2012年 03月 14日(三.) 18:05
 

/*
一仁  10  林宣含
structure
*/
#include<stdlib.h>
#include <stdio.h>
int main(void)
{
    int i,j;
    struct student
    {
           char id[15];
           char name[20];
           double mid_score;
           double fin_score;
           double usu_score;
           double final;
    }st[10],x;
   printf("please print the student's name;id;midterm score;final score;usual score\neach student change the lines\n");
   for(i=0;i<10;i++)
   {
       scanf("%s %s %lf %lf %lf",&st[i].name,&st[i].id,&st[i].mid_score,&st[i].fin_score,&st[i].usu_score);
      
   }
   for(i=0;i<10;i++)
   {
       st[i].final=st[i].mid_score+0.3*st[i].fin_score+0.4*st[i].usu_score;
      
   }
   for(i=0;i<10;i++)//排列
    {
         for(j=i+1;j<10;j++)
         {
          if(st[i].final<st[j].final)
          {
   x=st[j];
   st[j]=st[i];
   st[i]=x;
    }
         }
    }
    printf("\n");
   for(i=0;i<10;i++)
    {
         printf("%s %s %.0lf %.0lf %.0lf %.0lf\n",st[i].name,st[i].id,st[i].mid_score,st[i].fin_score,st[i].final);
     }                           
system ("pause");
return 0;
}
/*
please print the student's name;id;midterm score;final score;usual score
each student change the lines
Anny    10030101 98 96 95
Mary    10030102 87 65 92
Jack    10030103 99 87 100
Jemery    10030104 95 92 99
Sandy    10030105 66 52 82
Sophia    10030106 54 52 88
Anita    10030107 88 92 98
Kiki    10030108 98 92 90
Anthony    10030109 66 76 86
Rose    10030110 88 94 92

Jack 10030103 99 87 165 24763806146986196000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000
Anny 10030101 98 96 165 24763806146986196000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000
Jemery 10030104 95 92 162 247638061469861960000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000
Kiki 10030108 98 92 162 24763806146986196000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000
Anita 10030107 88 92 155 2476380614698619600000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000
Rose 10030110 88 94 153 24763806146986196000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000
Mary 10030102 87 65 143 24763806146986196000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000
Anthony 10030109 66 76 123 24763806146986196000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000
Sandy 10030105 66 52 114 2476380614698619600000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000
Sophia 10030106 54 52 105 247638061469861960000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000
請按任意鍵繼續 . . .
*/