diff --git a/README.md b/README.md index bb1afe6..8a29bd7 100644 --- a/README.md +++ b/README.md @@ -657,7 +657,7 @@ function ReadScore(STU stu[],int n,int m) do int i,j; printf "Input student's ID ,name and score:\n" for from i=0 to n-1 do //输入n个同学 - + input stu[i].num,stu[i].name for form j=0 to m-1 do //输入m门成绩 input stu[i].score[j] @@ -669,312 +669,264 @@ end //函数功能:计算每个学生各门课程的总分和平均分 ``` -void AverSumofEveryStudent(STU stu[],int n,int m) -{ +function AverSumofEveryStudent(STU stu[],int n,int m) do int i,j; - for(i=0;i0 ? stu[i].sum /m : -1; - printf("student %d: sum = %.0f,aver = %.0f\n",i+1,stu[i].sum,stu[i].aver); - } -} + printf "student %d: sum = %.0f,aver = %.0f\n" + end +end ``` //函数功能:计算每门课程的总分和平均分 ``` -void AverSumofEveryCourse(STU stu[],int n,int m) -{ +function AverSumofEveryCourse(STU stu[],int n,int m) do int i,j; float sum[COURSE_NUM],aver[COURSE_NUM]; - for(j=0;j b; // 这样比较决定了按降序排序,如果 a>b,则交换 -} +end ``` //交换两个单精度浮点型数据 ``` -void SwapFloat(float *x,float *y) -{ +function SwapFloat(float *x,float *y) do float temp; temp = *x; *x = *y; *y = temp; -} +end ``` //交换两个长整型数据 ``` -void SwapLong(long *x,long *y) -{ +function SwapLong(long *x,long *y) do long temp; temp = *x; *x = *y; *y = temp; -} +end ``` //交换两个字符串 ``` -void SwapChar(char x[],char y[]) -{ +function SwapChar(char x[],char y[]) do char temp[MAX_LEN]; strcpy(temp, x); strcpy(x, y); strcpy(y, temp); -} +end ``` //函数功能:按选择法将数组 num 的元素从低到高排序 ``` -void AsSortbyNum(STU stu[],int n,int m) -{ +function AsSortbyNum(STU stu[],int n,int m) do int i, j, k, t; - for (i=0; i=0&&stu[i].score[j]<60) t[0]++; - else if(stu[i].score[j]<70) t[1]++; - else if(stu[i].score[j]<80) t[2]++; - else if(stu[i].score[j]<90) t[3]++; - else if(stu[i].score[j]<100) t[4]++; - else if(stu[i].score[j]==100) t[5]++; - } - for(i=0;i<=5;i++) - { - if(i==0) printf("<60\t%d\t%.2f%%\n",t[i],(float)t[i]/n*100); - else if(i==5) printf("%d\t%d\t%.2f%%\n",(i+5)*10,t[i],(float)t[i]/n*100); - else printf("%d-%d\t%d\t%.2f%%\n",(i+5)*10,(i+5)*10+9,t[i],(float)t[i]/n*100); - } - } -} + for from i=0 to n-1 do + if stu[i].score[j]>=0&&stu[i].score[j]<60 set t[0]++ + else if stu[i].score[j]<70 set t[1]++; + else if stu[i].score[j]<80 set t[2]++; + else if stu[i].score[j]<90 set t[3]++; + else if stu[i].score[j]<100 set t[4]++; + else if stu[i].score[j]==100 set t[5]++; + end + for from i=0 to 4 do + if i==0 printf "<60\t%d\t%.2f%%\n" + else if i==5 printf "%d\t%d\t%.2f%%\n" + else printf "%d-%d\t%d\t%.2f%%\n" + end + end +end ``` //函数功能:打印学生成绩 ``` -void PrintScore(STU stu[],int n,int m) -{ +function PrintScore(STU stu[],int n,int m) do int i,j; - for (i=0; i