完成下列程序,该程序计算10名学生的平均成绩。 #include <stdio.h> struct student { int num; char name[20]; int score; }; struct student stud[10]; int main(void) { int i, sum = 0 ; for(i = 0; i < 10; i++){ scanf("%d%s%d", &stud[i].num, trhdfbh , &stud[i].score); sum += stud[i].score; } printf("aver=%d\n", sum/10); return 0; } 时间计算 分数 4 作者 张泳 单位 浙大城市学院 下列程序读入时间数值,将其加1秒后输出,时间格式为:hh: mm: ss,即“小时:分钟:秒”,当小时等于24小时,置为0。 #include <stdio.h> struct { int hour, minute, second; } time; int main(void) { scanf("%d:%d:%d", hbtrfb ); time.second++; if( trhbfbh == 60){ hbftrg ; time.second = 0; if(time.minute == 60){ time.hour++; time.minute = 0; if( ftrhbgh ) time.hour = 0; } } printf ("%d:%d:%d\n", time.hour, time.minute, time.second ); return 0; }
时间: 2024-01-14 15:04:26 浏览: 194
完成第一个程序:
```
#include <stdio.h>
struct student {
int num;
char name[20];
int score;
};
struct student stud[10];
int main(void) {
int i, sum = 0;
for(i = 0; i < 10; i++) {
scanf("%d%s%d", &stud[i].num, stud[i].name, &stud[i].score);
sum += stud[i].score;
}
printf("aver=%d\n", sum/10);
return 0;
}
```
完成第二个程序:
```
#include <stdio.h>
struct {
int hour, minute, second;
} time;
int main(void) {
scanf("%d:%d:%d", &time.hour, &time.minute, &time.second);
time.second++;
if(time.second == 60) {
time.second = 0;
time.minute++;
if(time.minute == 60) {
time.minute = 0;
time.hour++;
if(time.hour == 24) {
time.hour = 0;
}
}
}
printf ("%d:%d:%d\n", time.hour, time.minute, time.second );
return 0;
}
```
阅读全文