- 注册时间
- 2004-10-13
- 最后登录
- 2019-5-15
⑧专业
*永恒国度*
- 积分
- 14145

|
程序如下:- #include<stdio.h>
- #include<stdlib.h>
- struct stud
- {
- int num;
- char name[20];
- float score[3];
- }student[2];
- void main()
- {
- void abc(struct stud numb[]);
- int i,j;
- char number[20];
- for(i=0;i<2;i++)
- {
- gets(number); student[i].num=atoi(number);
- gets(student[i].name);
- for(j=0;j<3;j++)
- {
- gets(number); student[i].score[j]=atof(number);
- }
- }
- printf("\n num name score1 score2 score3\n");
- for(i=0;i<2;i++)
- {
- printf("%2d %8s ",student[i].num,student[i].name);
- for(j=0;j<3;j++)
- printf("%18f",student[i].score[j]);
- printf("\n");
- }
- abc(student);
- }
- void abc(struct stud numb[])
- {
- float b,c;
- int k,l;
- for(k=0;k<1;k++)
- {
- for(l=0;l<3;l++)
- b=b+numb[k].score[l];
- }
-
- printf("第一学生总成绩%d\n",b);
-
-
- }
复制代码 为什么最后的那个函数无法输出正确的值呢?应该怎么写??[s:6] |
|