| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 984 人关注过本帖
标题:[原创]关于学生成绩查询修改的程序
只看楼主 加入收藏
xw2014
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2006-1-17
收藏
 问题点数:0 回复次数:6 
[原创]关于学生成绩查询修改的程序
     定义一个班的学生(不多于100),包括姓名,学号,性别,输入学号或者姓名就可以得到他的成绩(语文,数学,外语,总分,均分),并且可以修改,这个程序应该是怎么样的思路呢 ?谢谢大家!
搜索更多相关主题的帖子: 学生 查询 
2006-03-28 22:10
C白痴
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-3-29
收藏
得分:0 
数组肯定有,其他的。....我这个C白痴就不知道了。
在这做个沙发,以后回来学习...

2006-03-29 01:43
︷順⑦?zì繎
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2006-3-28
收藏
得分:0 
可以用结构体来试试

2006-03-29 08:13
cuckoos123
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-3-25
收藏
得分:0 

可以用二维矩阵来存储学生信息,然后再设置索引应该就可以了吧

2006-03-29 14:08
xw2014
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2006-1-17
收藏
得分:0 

这是我写的,不过还有错误,不能编译通过。我刚学,很多都不会,希望大家多多指教!
/* student_score.c */
#define max 100

#include "stdio.h"
#include "conio.h"

struct date
{
float chinese;
float math;
float english;
float computer;
float summary;
float average;
}

struct student
{
int number;
char name[20];
char sex;
struct date score;
}student[max],*point;


print_information(int i)
{
printf("%d %c %s:\nchinese:%f english:%f computer:%f summary:%f average:%f\n",student[i].number,student[i].sex,student[i].name,student[i].score.chinese,student[i].score.math,student[i].score.english,student[i].score.computer,student[i].score.summary,student[i].score.average);
}


scanf_information(int i)
{
printf("please input the student's number:");
scanf("%d",&student[i].number);
printf("\nplease input the student's sex:");
scanf("%c",&student[i].sex);
printf("\nplease input the student's name:");
scanf("%s",student[i].name);
printf("\nplease input the score of chinese,math,english and computer:");
scanf("%f,%f,%f",&student[i].score.chinese,&student[i].score.math,&student[i].score.english,&student[i].score.computer);
student[i].score.summary=student[i].score.chinese+student[i].score.math+student[i].score.english+student[i].score.computer;
student[i].sco e.average=student[i].score.summary/4.0;
}

void bubblesort(int *point,int index)
{
int i,j;
int temp;
int change;
while(!change)
{
change=1;
for(j=index;j>0;j--)
for(i=0;i<j-1;i++)
if(point[i]>point[i+1])
{temp=point[i+1];
point[i+1]=point[i];
point[i]=temp;
change=0;
}
}
}


main()
{
int biaohao;
int i,selection;
int counter;
printf("please input the number of student:");
scanf("%d",&count);
if(count>=100)
printf("please input a number less than 100");
else
{
printf("please input the student's information:\n");
for(i=0;i<counter;i+=)
scanf_information(i);
bubblesort(student *point,count);
printf("\nfinal sorting result:");
for(i=0;i<counter;i++)
print_information(i);
printf("if you choose 1.Display student information\n");
printf("if you choose 2.Modify student information\n");
printf("if you choose 3 will quit\n");
printf("please input your choose:");
scanf("%d",&selection);

if(selection==1||selection==2)
{
printf("please input the student number:");
scanf("%d",&biaohao);
if(biaohao<100)
printf_information(biaohao);
else
{printf("the error student number!:");
printf("please input again\n");
}
}

swith(selection)
{case 1:break;
case 2:printf("please input the student's information:\n");
scanf_information(bianhao);
student[counter].score.chinese=student[biaohao].score.chinese;
student[counter].score.math=student[biaohao].score.math;
student[counter].score.english=student[biaohao].score.english;
student[counter].score.computer=student[biaohao].score.computer;
student[counter].score.summary=student[biaohao].score.summary;
student[counter].score.average=student[biaohao].score.average;
break;
case 3:break;
}
}
}


2006-03-30 22:50
SunShining
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:31
帖 子:2215
专家分:0
注 册:2006-2-17
收藏
得分:0 

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct student
{
int number;
char name[20];
int chinese;
int math;
int english;
int sum;
float avg;
}stu[99];


/*菜单程序*/
int menu()
{
int num,i;
printf("\n*******************************************************\n\n");
printf("\t\t--------------------------------\n");
printf("\t\t+ The Student message choose +\n");
printf("\t\t+ 1.Input student message +\n");
printf("\t\t+ 2.Screen student score +\n");
printf("\t\t+ 3.Change student score +\n");
printf("\t\t+ 4.Delete student score +\n");
printf("\t\t+ 5.Taxis student score +\n");
printf("\t\t+ 6.Search student score +\n");
printf("\t\t+ 7.Safly esc computer +\n");
printf("\t\t+ ->Student mange computer<- +\n");
printf("\t\t--------------------------------\n");

for(i=0;i<10;i++)
{
printf("\nPlease input choice:");
scanf("%d",&num);
if(num<=7 && num>=1)
{
printf("\n***********************Starting***********************\n\n");
break;
}
else printf("注意: Input mistake Please repeat to input!\n");
}
return (num);
}


/*输入学生信息*/
int in_put(struct student stu[99])
{
int num,i;
printf("How many students do you want to input: ");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("\nPlease input student number: ");
scanf("%d",&stu[i].number);

printf("\nPlease input student name:");
gets(stu[i].name);
gets(stu[i].name);
printf("\nPlease input student chinese score: ");
scanf("%d",&stu[i].chinese);
printf("Please input student math score : ");
scanf("%d",&stu[i].math);
printf("Please input student english score: ");
scanf("%d",&stu[i].english);
stu[i].sum=stu[i].chinese+stu[i].math+stu[i].english;
stu[i].avg=stu[i].sum/3.0;
}
return (num);
}


/*显示学生信息*/
void all(struct student stu[99],int num)
{ int i;
if(num!=0)
{
printf("\n Number\t Name Chinese Math Eenlish Avg Sum\n");
for(i=0;i<num;i++)
{
if(stu[i].chinese!=-100)
{
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
}
}
}
else printf("\n\t\t\tThere is nothing!\n\n");
}


/*改变学生信息*/
void change(struct student stu[99],int num)
{
char change_name[20];
int a,i;
if(num!=0)
{
printf("Plerse input that will be changed student name: ");
gets(change_name);
gets(change_name);
for(i=0;i<num;i++)
{
if(strcmp(change_name,stu[i].name)==0 && stu[i].chinese!=-100)
{
printf("\n\nNumber\t Name Chinese Math English Avg Sum");
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
printf("\n\nWhose subject do you want to change %s \n",stu[i].name);
printf("1. Chinese\t 2. Math\t 3.English\n");
printf("Please choose mark: ");
scanf("%d",&a);
switch(a)
{
case 1:
printf("The chinese of %s is changed: ",stu[i].name);
scanf("%d",&stu[i].chinese);
printf("\n\t\tThe changing success\n");
stu[i].sum=stu[i].chinese+stu[i].math+stu[i].english;
stu[i].avg=stu[i].sum/3;
printf("Number\t Name Chinese Math English Avg Sum");
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
break;
case 2:
printf("The math of %s is changed: ",stu[i].name);
scanf("%d",&stu[i].math);
printf("\n\t\tThe changing success\n");
stu[i].sum=stu[i].chinese+stu[i].math+stu[i].english;
stu[i].avg=stu[i].sum/3;
printf("Number\t Name Chinese Math English Avg Sum");
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
break;
case 3:
printf("The English of %s is changed: ",stu[i].name);
scanf("%d",&stu[i].english);
printf("\n\t\tThe changing success\n");
stu[i].sum=stu[i].chinese+stu[i].math+stu[i].english;
stu[i].avg=stu[i].sum/3;
printf("Number\t Name Chinese Math English Avg Sum");
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
break;
default : printf("\n\t\tThe inputing mistake\n");break;
}
break;
}
else if(i==num-1)
{
printf("\n\t\tThe inputing mistake\n");
break;
}
}
}
else printf("\n\t\t\tThere is nothing\n\n");
}


/*删除学生信息*/

void del(struct student stu[99],int num)
{
char del_name[20];
char a;
int i;
if(num!=0)
{
printf("Please input who will be delete student's name: ");
gets(del_name);
gets(del_name);
for(i=0;i<num;i++)
{
if(strcmp(del_name,stu[i].name)==0 && stu[i].chinese!=-100)
{
printf("Do you Enter(y/n): ");
scanf("%c",&a);
if(a=='y' || a=='Y')
{
stu[i].chinese=-100;
printf("\n\t\tThe deleting success\n");
break;
}
break;
}
else if(i==num-1)
{
printf("\n\t\tThe inputing mistake\n");
break;
}
}
}
else printf("\n\t\t\tThere is nothing\n\n");
}

/*排序学生信息*/

void paixu(struct student stu[99],int num)
{
int a,i,j,number;
char name[20];
double temp;
if(num!=0)
{
printf("Please input the taxis object:(down)\n");
printf("1. Chinese\t 2. Math\t 3. English\t 4. Avg\t 5. Sum\n");
printf("Please choose mark: ");
scanf("%d",&a);
switch(a)
{
case 1:
for(i=0;i<num-1;i++)
{
for(j=i+1;j<num;j++)
{
if(stu[i].chinese<stu[j].chinese && stu[j].chinese!=-100)
{
number=stu[i].number; stu[i].number=stu[j].number; stu[j].number=number;
strcpy(name,stu[i].name); strcpy(stu[i].name,stu[j].name); strcpy(stu[j].name,name);
temp=stu[i].chinese; stu[i].chinese=stu[j].chinese; stu[j].chinese=temp;
temp=stu[i].math; stu[i].math=stu[j].math; stu[j].math=temp;
temp=stu[i].english; stu[i].english=stu[j].english; stu[j].english=temp;
temp=stu[i].avg; stu[i].avg=stu[j].avg; stu[j].avg=temp;
temp=stu[i].sum; stu[i].sum=stu[j].sum; stu[j].sum=temp;
}
}
}
printf("Number\t Name Chinese Math English Avg Sum");
for(i=0;i<num;i++)
{
if(stu[i].chinese!=-100)
{
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
}
}
break;
case 2:
for(i=0;i<num-1;i++)
{
for(j=i+1;j<num;j++)
{
if(stu[i].math<stu[j].math && stu[j].chinese!=-100)
{
number=stu[i].number; stu[i].number=stu[j].number; stu[j].number=number;
strcpy(name,stu[i].name); strcpy(stu[i].name,stu[j].name); strcpy(stu[j].name,name);
temp=stu[i].chinese; stu[i].chinese=stu[j].chinese; stu[j].chinese=temp;
temp=stu[i].math; stu[i].math=stu[j].math; stu[j].math=temp;
temp=stu[i].english; stu[i].english=stu[j].english; stu[j].english=temp;
temp=stu[i].avg; stu[i].avg=stu[j].avg; stu[j].avg=temp;
temp=stu[i].sum; stu[i].sum=stu[j].sum; stu[j].sum=temp;
}
}
}
printf("Number\t Name Chinese Math English Avg Sum");
for(i=0;i<num;i++)
{
if(stu[i].chinese!=-100)
{
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
}
}
break;
case 3:
for(i=0;i<num-1;i++)
{
for(j=i+1;j<num;j++)
{
if(stu[i].english<stu[j].english && stu[j].chinese!=-100)
{
number=stu[i].number; stu[i].number=stu[j].number; stu[j].number=number;
strcpy(name,stu[i].name); strcpy(stu[i].name,stu[j].name); strcpy(stu[j].name,name);
temp=stu[i].chinese; stu[i].chinese=stu[j].chinese; stu[j].chinese=temp;
temp=stu[i].math; stu[i].math=stu[j].math; stu[j].math=temp;
temp=stu[i].english; stu[i].english=stu[j].english; stu[j].english=temp;
temp=stu[i].avg; stu[i].avg=stu[j].avg; stu[j].avg=temp;
temp=stu[i].sum; stu[i].sum=stu[j].sum; stu[j].sum=temp;
}
}
}
printf("Number\t Name Chinese Math English Avg Sum");
for(i=0;i<num;i++)
{
if(stu[i].chinese!=-100)
{
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
}
}
break;
case 4:
for(i=0;i<num-1;i++)
{
for(j=i+1;j<num;j++)
{
if(stu[i].avg<stu[j].avg && stu[j].chinese!=-100)
{
number=stu[i].number; stu[i].number=stu[j].number; stu[j].number=number;
strcpy(name,stu[i].name); strcpy(stu[i].name,stu[j].name); strcpy(stu[j].name,name);
temp=stu[i].chinese; stu[i].chinese=stu[j].chinese; stu[j].chinese=temp;
temp=stu[i].math; stu[i].math=stu[j].math; stu[j].math=temp;
temp=stu[i].english; stu[i].english=stu[j].english; stu[j].english=temp;
temp=stu[i].avg; stu[i].avg=stu[j].avg; stu[j].avg=temp;
temp=stu[i].sum; stu[i].sum=stu[j].sum; stu[j].sum=temp;
}
}
}
printf("Number\t Name Chinese Math English Avg Sum");
for(i=0;i<num;i++)
{
if(stu[i].chinese!=-100)
{
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
}
}
break;
case 5:
for(i=0;i<num-1;i++)
{
for(j=i+1;j<num;j++)
{
if(stu[i].sum<stu[j].sum && stu[j].chinese!=-100)
{
number=stu[i].number; stu[i].number=stu[j].number; stu[j].number=number;
strcpy(name,stu[i].name); strcpy(stu[i].name,stu[j].name); strcpy(stu[j].name,name);
temp=stu[i].chinese; stu[i].chinese=stu[j].chinese; stu[j].chinese=temp;
temp=stu[i].math; stu[i].math=stu[j].math; stu[j].math=temp;
temp=stu[i].english; stu[i].english=stu[j].english; stu[j].english=temp;
temp=stu[i].avg; stu[i].avg=stu[j].avg; stu[j].avg=temp;
temp=stu[i].sum; stu[i].sum=stu[j].sum; stu[j].sum=temp;
}
}
}
printf("Number\t Name Chinese Math English Avg Sum");
for(i=0;i<num;i++)
{
if(stu[i].chinese!=-100)
{
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
}
}
break;
default : printf("\n\t\t输入有误!\n");break;
}
}
else printf("\n\t\t\t无信息!\n\n");
}

/*查看学生信息*/
void chakan(struct student stu[99],int num)
{
char name[20];
int a,b,i;
if(num!=0)
{
printf("Please input which you will choose the object: \n");
printf("1. Name \t 2. Number\t\n");
printf("Please choose mark: ");
scanf("%d",&a);
switch(a)
{
case 1:
printf("Please input what name you want to find : ");
gets(name);
gets(name);
for(i=0;i<num;i++)
{
if(strcmp(name,stu[i].name)==0 && stu[i].chinese!=-100)
{
printf("Number\t Name Chinese Math English Avg Sum");
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
break;
}
else if(i==num-1)
{
printf("\n\t\tThe Inputing is mistake\n");
break;
}
}
break;
case 2:
printf("Please input what number you want to find: ");
scanf("%d",&b);
for(i=0;i<num;i++)
{
if(b==stu[i].number && stu[i].chinese!=-100)
{
printf("Number\t Name Chinese Math English Avg Sum");
printf("-----------------------------------------------------------------------\n");
printf("%d %8s %d %d %d %5.2f %d\n\n",stu[i].number,stu[i].name,stu[i].chinese,stu[i].math,stu[i].english,stu[i].avg,stu[i].sum);
break;
}
else if(i==num-1)
{
printf("\n\t\tThe Inputing is mistake\n");
break;
}
}
break;
default : printf("\n\t\tThe Inputing is mistake\n");break;
}
}
else printf("\n\t\t\tThere is nothing\n\n");
}
main()
{
int chose,k=0;
struct student stu[99];
while(1)
{
chose=menu();
switch(chose)
{
case 1: k=in_put(stu);break;
case 2: all(stu,k);break;
case 3: change(stu,k);break;
case 4: del(stu,k);break;
case 5: paixu(stu,k);break;
case 6: chakan(stu,k);break;
case 7: printf("\n\t\tThe program has safely esced!\n\n\n");exit(0);break;
}
}
getch();
}

WIN-TC下运行.有什么差异的地方自己改.基本合你要求!


[glow=255,violet,2]闭关修炼ing...[/glow] [FLASH=360,180]http://www./chinaren.swf[/FLASH]
2006-03-31 11:23
SunShining
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:31
帖 子:2215
专家分:0
注 册:2006-2-17
收藏
得分:0 
功能比你的还要多..

[glow=255,violet,2]闭关修炼ing...[/glow] [FLASH=360,180]http://www./chinaren.swf[/FLASH]
2006-03-31 11:26
快速回复:[原创]关于学生成绩查询修改的程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050292 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved