100分急求高手帮帮忙!!!!!

[复制链接]
查看11 | 回复2 | 2009-6-5 18:17:03 | 显示全部楼层 |阅读模式
昨天写了个类型的,如果你给分,我再帮你写,反正这个很简单#include "stdafx.h"struct student{ char name[10]; int score;};student stu[20];void inputinfo(int n){ int i = 0; for (i = 0; i < n; i++) {printf("第%d个学生的姓名:",i+1);gets(stu.name);printf("第%d个学生的成绩:",i+1);scanf("%d",&stu.score);getchar();}}void displayinfo(int n){ int i = 0; printf("姓名\t\t分数\n"); for (i = 0; i < n; i++) {printf("%s\t\t%d\n",stu.name,stu.score); } }void max_and_min(int n){ printf("Max = %d\n",stu[0].score); printf("Min = %d\n",stu[n-1].score);}void souce_from_higt_to_low(int n){ int indexi; int indexj; student _temp;for (indexi = 0; indexi < n;indexi++) {for (indexj = indexi+1; indexj < n; indexj++){ if (stu[indexi].score < stu[indexj].score) {
_temp = stu[indexj];
stu[indexj] = stu[indexi];
stu[indexi] = _temp; }} } printf("数学分数从高到低排列:\n"); displayinfo(n);} int main(int argc,char *argv[]){ inputinfo(20); displayinfo(20); souce_from_higt_to_low(20); displayinfo(20); max_and_min(20);return 0;}
回复

使用道具 举报

千问 | 2009-6-5 18:17:03 | 显示全部楼层
看看这个,可以就给分#include "stdio.h"#define N 10struct student{char name[10]; int mathscore; int englishscore; int computerscore;};student stu[N];void inputinfo(int n){ int i = 0;for (i = 0; i < n; i++) {printf("第%d个学生的姓名:",i+1);gets(stu.name);
printf("第%d个学生的成绩数学成绩:",i+1);scanf("%d",&stu.mathscore);printf("第%d个学生的英语成绩:",i+1);scanf("%d",&stu.englishscore);printf("第%d个学生的计算机成绩:",i+1);scanf("%d",&stu.computerscore);getchar();}}void displaymathscore(int n){ int i = 0; printf("序号\t\t姓名\t\t分数\n"); for (i = 0; i < n; i++) {printf("%d\t\t%s\t\t%d\n",i+1,stu.name,stu.mathscore); } }void displayenglishscore(int n){ int i = 0; printf("序号\t\t姓名\t\t分数\n"); for (i = 0; i < n; i++) {printf("%d\t\t%s\t\t%d\n",i+1,stu.name,stu.englishscore); } }void displaycomputerscore(int n){ int i = 0; printf("序号\t\t姓名\t\t分数\n"); for (i = 0; i < n; i++) {printf("%d\t\t%s\t\t%d\n",i+1,stu.name,stu.computerscore); } }void souce_from_higt_to_low(int n){ int indexi; int indexj; student _temp;for (indexi = 0; indexi < n;indexi++) {for (indexj = indexi+1; indexj < n; indexj++){ if (stu[indexi].mathscore < stu[indexj].mathscore) {
_temp = stu[indexj];
stu[indexj] = stu[indexi];
stu[indexi] = _temp; }} }printf("数学分数从高到低排列:\n"); displaymathscore(n); for (indexi = 0; indexi < n;indexi++) {for (indexj = indexi+1; indexj < n; indexj++){ if (stu[indexi].englishscore < stu[indexj].englishscore) {
_temp = stu[indexj];
stu[indexj] = stu[indexi];
stu[indexi] = _temp; }} }printf("英语分数从高到低排列:\n"); displayenglishscore(n); for (indexi = 0; indexi < n;indexi++) {for (indexj = indexi+1; indexj < n; indexj++){ if (stu[indexi].computerscore < stu[indexj].computerscore) {
_temp = stu[indexj];
stu[indexj] = stu[indexi];
stu[indexi] = _temp; }} }printf("计算机分数从高到低排列:\n"); displaycomputerscore(n);} int main(int argc,char *argv[]){ inputinfo(3); souce_from_higt_to_low(3);return 0;}
回复

使用道具 举报

千问 | 2009-6-5 18:17:03 | 显示全部楼层
先采纳了,马上做,信就成交,可加加好友先不想白做而已!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行