📄 xshchj.cpp
字号:
//3.编写一个程序,输入N个学生的学号和成绩,输出高于平均成绩的学生的学号和成绩,其中学号和成绩均为整数
//不能使用数组
#include <stdio.h>
struct stu
{
int num;
int score;
};
int student(int total,int n)//total....总分,n.....学生个数
{
struct stu s;
int ave;
printf("please input the number of the student:\n");
scanf("%d",&s.num);
if(s.num!=0)
{
printf("please input the score of the student %d:\n",s.num);
scanf("%d",&s.score);
ave=student(s.score+total,n+1);// 返回平均分
if(s.score>ave)
printf("%d,%d\n",s.num,s.score);
return ave;
}
else return (total/n);//计算平均分
}
int main(int agrc ,char*agrv)
{
printf("%d",student(0,0));
printf("\n");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -