C综合练习-4附参考答案

2026/4/28 4:08:56

易读文库

{int i, j, p ;struct student t; /* 工作变量 */

/* 输入1000个学生的记录,包括学号、姓名和三门课成绩,并计算个人的平均分 */ printf(“\\nInput the student’s number,name and scores:”); for(i = 0; i < 1000; i++) { printf(“No %d \\n”,i+1); /* 提示输入第i个同学的信息 */

scanf(“%d,%s,%d,%d,%d”, &stud[i].num, stud[i].name, &stud[i].score[0],&stud[i].score[1],&stud[i].score[2]); stud[ i ].avr = (stud[i].score[ 0 ]+ stud[i].score[ 1 ]+ stud[i].score[ 2 ]) /3.0 ; }

/*使用选择法排序,按照平均分从低到高排序 */ for(i = 0; i < 999; ++i) { p = i;

for(j = i + 1; j < 1000; j++ )

if(stud[j].avr < stud[p].avr ) p = j;

t=stud[p]; stud[p]=stud[i];stud[i]=t;}

/* 输出 */

printf(“The student score:\\n”); for(i = 999; i >= 0; i--)

printf(“%d %s %f\\n”, stud[i].num, stud[i].name, stud[i].avr); } 2. #include \ #include \ void main()

{ FILE *fp; char ch;

int line=1;

if((fp=fopen(“d:/a.txt”,”r ”))==NULL){ printf(\ exit(0); }

while(!feof(fp)){

ch=fgetc(fp);

if(ch>='A'&&ch<='Z') ch+=32; putchar(ch);

if(ch=='\\n') line++; } fclose(fp);

printf(\总行数 %d\\n\

读出字符和大写转小写处理


C综合练习-4附参考答案.doc 将本文的Word文档下载到电脑
搜索更多关于: C综合练习-4附参考答案 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219