只做了第一题,为什么要用两个数组啊, 挺烦的!!!
以下为简单的实现函数没有错误处理的
#include
#include
int score[50][4];
char name[50][20];
int count;
int func1()
{
while (count < 50) //如果50测试比较麻烦的话,可以修改少量的,修改这里就可以了
{
int i = 0, maths, eng, clan, sum;
printf("input name:");
scanf("%s", &name[count]);
printf("input maths:");
scanf("%d", &maths);
score[count][i] = maths;
i++;
printf("input english:");
scanf("%d", &eng);
score[count][i] = eng;
i++;
printf("input C-language:");
scanf("%d", &clan);
score[count][i] = clan;
i++;
sum = maths + eng + clan;
score[count][i] = sum;
count++;
printf(" ---------------------------- \n");
}
return 0;
}
int func2(int a[50][4])
{
int i, j;
for (i = 0; i < count - 1; i++)
{
for (j = i+1; j < count; j++)
{
if (a[i][3] > a[j][3])
{
int tmp = a[i][3];
char ttt[20];
strcpy(ttt, name[i]);
a[i][3] = a[j][3];
strcpy(name[i], name[j]);
a[j][3] = tmp;
strcpy(name[j], ttt);
}
}
}
}
int main()
{
int i, j = 0;
func1();
func2(score);
for (i = 1, j = count - 1; j >= 0; j--, i++)
printf("%d: %s\n", i, name[j]);
return 0;
}
这个题太费脑子和体力 给分吧 150分 我给你做
哥们儿你找人给你写作业呢?一道题多少钱啊?
一道题多少钱啊?