帮忙做做C语言的复习题 谢了

来源:百度知道 编辑:UC知道 时间:2024/06/01 22:48:28
1.从键盘输入二个数,求最大数
2.任意给出几个数,求其中正数的平均值
3.求100以内奇数之和
4.用选择法对几个数进行排序
5.把从终端输入一行字符串,所有的小写字母转换成大写字母输出,其他不变
★6.有一个班,3个学生,各学4门课,求每个同学的平均成绩和全班最高成绩并输出

恩,上面那些都很好,这个是用结构体做的,不妨参考:
#include<stdio.h>
void main()
{
int n;
float max;
struct student
{
int math;
int english;
int chinese;
int computer;
float av;
}st[3]={{80,79,82,88},{85,89,90,70},{90,98,92,78}};
for(int i=0;i<3;i++)
{
st[i].av=(st[i].math+st[i].english+st[i].computer+st[i].chinese)/4.0;
printf("the average of st[%d]:%f\n",i,st[i].av);
}
max=st[i].av;
for( i=0;i<3;i++)
{
if(max<st[i+1].av)
{
n=max;
max=st[i+1].av;
st[i+1].av=n;
}
}
printf("max:\n :%f", max*4);
}

1,void main()
{
int a, b;
printf("输入2个数: ");
scanf("%d %d", &a, &b);
printf("\n%d 较大\n", a>b ? a : b);
}