c语言课程设计 学生成绩管理系统

作者&投稿:和韵 (若有异议请与网页底部的电邮联系)
C语言课程设计学生成绩管理系统 功能:学生成绩管理系统,每个学~

参考以下,部分代码改了即可:首先将记录储存再TXT文件下,格式如下所示:学号姓名性别等级笔试机试类别1张三男二级66772李四男三级88993张二男二级40604李二女二级50595王五女三级99996王三男二级77617刘四男四级60598刘五女二级88779张五女二级648110李六女二级5930-------------------------------------------------------------代码如下,本人亲自编写,无错误通过--------------------------------------------------------------------#include#include#include#includeusingnamespacestd;voidadd_information(stringstr);voiddelete_information(stringstr);voidedit_information(stringstr);voidscanf_information(stringstr);voidscore_scanf(stringstr);voidpingfen(stringstr);voidpass_total(stringstr);main(){cout>number;stringname;//统计用的科目名switch(number){case1:cout>number;switch(number){case1:add_information(str);break;case2:delete_information(str);break;case3:edit_information(str);break;case4:scanf_information(str);break;default:cout>a>>b>>c>>d>>e>>f;outstream.precision(6);//显示精度outstreamname_1;stringa,b,c,d,e,f;ofstreamoutstream;//暂存的中间文件outstream.open("temp.txt");boolflag=0;//是否查找到while(1){//删除操作,自己感觉都有点麻烦instream>>a>>b>>c>>d>>e>>f;if(name_1!=a){outstreamname_1;stringa,b,c,d,e,f;ofstreamoutstream;//暂存的中间文件outstream.open("temp.txt");boolflag=0;//是否查找到while(1){//删除操作,自己感觉都有点麻烦instream>>a>>b>>c>>d>>e>>f;if(name_1==a){//找到修改的记录flag=1;cout>a>>b>>c>>d>>e>>f;}outstreama>>b>>c>>d>>e>>f;coutname_1;stringa,b,c,d,e,f,g;boolflag=0;//是否查找到while(1){//删除操作,自己感觉都有点麻烦instream>>a>>b>>c>>d>>e>>f>>g;if(name_1==g){//找到修改的记录flag=1;couta>>b>>c>>d>>e>>f;outstream=85)outstream=70&&f=60&&f=70&&e=70)outstream=60&&f=60&&e=60)outstreama>>b>>c>>d>>e>>f>>g;if(g=="优秀"||g=="良好"||g=="及格")count++;if(instream.eof())break;}cout<<"合格的人数为:"<

#include "stdio.h"
#define N 10
struct student
{char num[10];
char name[20];
float score[3];
float sum;
float aver;
}stu[N];
void main()
{
void count(struct student stu[]);
void sort(struct student stu[]);
void find(struct student stu[]);
int i;
float temp;
for(i=0;i<N;i++)
{printf("enter data of the%dth student:
",i+1);
printf("number: ");
gets(stu[i].num);
printf("name: ");
gets(stu[i].name);
printf("score1: ");
scanf("%f",&temp);
stu[i].score[0]=temp;
printf("score2: ");
scanf("%f",&temp);
stu[i].score[1]=temp;
printf("score3: ");
scanf("%f",&temp);
getchar();
stu[i].score[2]=temp;
}
count(stu);
printf("
");
sort(stu);
printf("
");
find(stu);
}

void count(struct student stu[])
{float sum,aver;
int i,j;
for(i=0;i<N;i++)
{sum=0;
for(j=0;j<3;j++)
sum+=stu[i].score[j];
aver=sum/3.0;
stu[i].sum=sum;
stu[i].aver=aver;
}
printf("number name sum average
");
for(i=0;i<N;i++)
printf("%-8s%-10s%-9.2f%-9.2f
",stu[i].num,stu[i].name,stu[i].sum,stu[i].aver);
}

void sort(struct student stu[])
{int i,j,k;
struct student temp;
for(i=0;i<N;i++)
{k=i;
for(j=i+1;j<N;j++)
if(stu[k].sum<stu[j].sum)k=j;
if(k!=i)
{temp=stu[i];
stu[i]=stu[k];
stu[k]=temp;}
}
printf("number name score1 score2 score3 sum average
");
for(i=0;i<N;i++)
printf("%-8s%-10s%-8.2f%-8.2f%-8.2f%-8.2f%-8.2f
",stu[i].num,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].sum,stu[i].aver);
}

void find(struct student stu[])
{int i,j,sum,flag=0;
printf("the student of two scores<60:
");
for(i=0;i<N;i++)
{
sum=0;
for(j=0;j<3;j++)
if(stu[i].score[j]<60)sum++;
if(sum>=2)
{flag=1;
printf("%-8s%-10s
",stu[i].num,stu[i].name);
}
}
if(flag==0)
printf(" not exist!
");
}

#include<fstream.h>
#include<process.h>
#include<iomanip.h>
#include<string.h>

class Student
{
public:
Student();
~Student();
void add_info();
void del_info();
void search_info_cell();
void out_all_info();
int get_info();
protected:
char name[10];
char sex[3];
char nationality[7];
char nation[8];
char diploma[6];
char birthday[8];
char address[6];
long cell;
long family;
long school;
int chinese,English,math,physics;
Student *head,*next;
};
/**
*构造函数,用来创建对象同时初始化相关指针变量
*/
Student::Student()
{
head=NULL;
next=NULL;
}
/**
*从文件中获取学生的信息
*/
int Student::get_info()
{
Student *temp,*loop;
temp=new Student();
loop=new Student();
ifstream out_file;
out_file.open("stuinfo.txt",ios::beg);//打开文件,设置读指针在文件的开头
if(!out_file)
{
cout<<"从文件中获取信息失败!";
cout<<"\n按任意键退出.";
cin.get();
exit(0);//结束程序
}
while(!out_file.eof())//循环读文件,直到读到了文件的末尾
{
//文件的结构是:文件的一行就是一个学生的信息, 从左到右是: 电话号 姓名 性别 民族 地址 国籍 学历 出生日期 语文 英语 数学 物理
//这些信息可以在本程序提供的功能生成并保存到文件里
out_file>>(temp->cell)>>(temp->name)>>(temp->sex)>>(temp->nation)>>(temp->address)>>(temp->nationality )>>
(temp->diploma)>>(temp->birthday)>>(temp->chinese)>>(temp->English)>>(temp->math)>>(temp->physics);
if(temp->cell==0) break;
//使用链表把学生的信息保存到内存中
if(head==NULL) head=temp;
else
{
if(head->cell>temp->cell)
{
temp->next=head;
head=temp;
}
else
{
loop=head;
while(loop->next!=NULL)
{
if(loop->next->cell>temp->cell)
{
temp->next=loop->next;
loop->next=temp;
break;
}
loop=loop->next;
}
if(loop->next==NULL)
{
loop->next=temp;
temp->next=NULL;
}
}
}
temp=new Student;
loop=new Student;
}
out_file.close();//关闭文件
if(head==NULL) return 0;
else return 1;
}

/**
*输出所有学生的信息
*/
void Student::out_all_info()
{
Student*temp;
temp=new Student;
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<"学生信息如下:"<<endl<<endl;
cout<<setw(7)<<"电话"<<setw(7)<<"姓名"<<setw(5)<<"性别"<<setw(8)<<"民族"<<setw(8)<<"地址"<<setw(8)<<"国籍"<<setw(6)
<<"学历"<<setw(9)<<"生日"<<setw(5)<<"语文"<<setw(5)<<"英语"<<setw(5)<<"数学"<<setw(5)<<"物理"<<endl;
cout<<endl;
temp=head;
while(temp!=NULL)//循环读链表,输出所有学生的信息
{
cout<<setw(7)<<(temp->cell)<<setw(7)<<(temp->name)<<setw(5)<<(temp->sex)<<setw(8)<<(temp->nation)<<setw(8)<<(temp->address)<<setw(8)
<<(temp->nationality)<<setw(6)<<(temp->diploma)<<setw(9)<<(temp->birthday)<<setw(5)<<(temp->chinese)<<setw(5)<<(temp->English)
<<setw(5)<<(temp->math)<<setw(5)<<(temp->physics)<<endl<<endl;
temp=temp->next;
}
}
/**
*通过学号查找信息
*/
void Student::search_info_cell()
{
Student*temp;
long num;
temp=new Student;
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<"输入要查找学生电话号码:";
cin>>num;//输入手机号
temp=head;
while(temp!=NULL&&temp->cell!=num)//比较学号
temp=temp->next;
if(temp==NULL)//没有找到信息
cout<<"对不起,没有这个学生!"<<endl;
else//输出信息
{
cout<<"学生信息如下: "<<endl;
cout<<setw(7)<<"电话"<<setw(7)<<"姓名"<<setw(5)<<"性别"<<setw(8)<<"民族"<<setw(8)<<"地址"<<setw(8)<<"国籍"<<setw(6)
<<"学历"<<setw(9)<<"生日"<<setw(5)<<"语文"<<setw(5)<<"英语"<<setw(5)<<"数学"<<setw(5)<<"物理"<<endl;
cout<<setw(7)<<(temp->cell)<<setw(7)<<(temp->name)<<setw(5)<<(temp->sex)<<setw(8)<<(temp->nation)<<setw(8)<<(temp->address)<<setw(8)
<<(temp->nationality)<<setw(6)<<(temp->diploma)<<setw(9)<<(temp->birthday)<<setw(5)<<(temp->chinese)<<setw(5)<<(temp->English)
<<setw(5)<<(temp->math)<<setw(5)<<(temp->physics)<<endl;
}
}
/**
*增加学生的信息
*/
void Student::add_info()
{
Student *temp,*loop,*loop1;
temp=new Student;
loop=new Student;
loop1=new Student;
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<"现在增加学生信息:"<<endl;
{ cout<<"输入电话号码:";
cin>>temp->cell;//输入手机号
cout<<"输入姓名:";
cin>>temp->name;//姓名
cout<<"输入性别:";
cin>>temp->sex;
cout<<"输入民族:";
cin>>temp->nation;
cout<<"输入地址:";
cin>>temp->address;
cout<<"输入国籍:";
cin>>temp->nationality;
cout<<"输入学历:";
cin>>temp->diploma;
cout<<"输入生日:";
cin>>temp->birthday;
cout<<"输入语文分数:";
cin>>temp->chinese;//语文
cout<<"输入英语分数:";
cin>>temp->English;//英语
cout<<"输入数学分数:";
cin>>temp->math;//数学
cout<<"输入物理分数:";
cin>>temp->physics;//物理
if(head==NULL) head=temp;//将信息添加到链表中
else
{
if(head->cell>temp->cell)
{
temp->next=head;
head=temp;
}
else
{
loop=head;
while(loop->next!=NULL)
{
if(loop->next->cell>temp->cell)
{
temp->next=loop->next;
loop->next=temp;
break;
}
loop=loop->next;
}
if(loop->next==NULL)
{
loop->next=temp;
temp->next=NULL;
}
}
}
}
cout<<"\n您输入学生信息如下:"<<endl;
cout<<setw(7)<<"手机"<<setw(7)<<"姓名"<<setw(5)<<"性别"<<setw(8)<<"民族"<<setw(8)<<"地址"<<setw(8)<<"国籍"<<setw(6)
<<"学历"<<setw(9)<<"生日"<<setw(5)<<"语文"<<setw(5)<<"英语"<<setw(5)<<"数学"<<setw(5)<<"物理"<<endl;
cout<<setw(7)<<(temp->cell)<<setw(7)<<(temp->name)<<setw(5)<<(temp->sex)<<setw(8)<<(temp->nation)<<setw(8)<<(temp->address)<<setw(8)
<<(temp->nationality)<<setw(6)<<(temp->diploma)<<setw(9)<<(temp->birthday)<<setw(5)<<(temp->chinese)<<setw(5)<<(temp->English)
<<setw(5)<<(temp->math)<<setw(5)<<(temp->physics)<<endl;
}
/**
*通过学号删除信息
*/
void Student::del_info()
{
Student *temp,*loop1,*loop2;
long cell;
temp=new Student;
loop1=new Student;
loop2=new Student;
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<"输入要删除学生电话号码:";
cin>>cell;//输入电话号
temp=head;
while(temp!=NULL&&temp->cell!=cell)//通过手机号查找信息
{
loop1=temp;
temp=temp->next;
}
if(temp==NULL)//没有相应学号的学生信息
cout<<"抱歉,没有该学生!"<<endl;
else
{
loop1->next=temp->next;//跳过链表的一个节点temp
cout<<"您删除的学生信息如下:"<<endl;
cout<<setw(7)<<"手机"<<setw(7)<<"姓名"<<setw(5)<<"性别"<<setw(8)<<"民族"<<setw(8)<<"地址"<<setw(8)<<"国籍"<<setw(6)
<<"学历"<<setw(9)<<"生日"<<setw(5)<<"语文"<<setw(5)<<"英语"<<setw(5)<<"数学"<<setw(5)<<"物理"<<endl;
cout<<setw(7)<<(temp->cell)<<setw(7)<<(temp->name)<<setw(5)<<(temp->sex)<<setw(6)<<(temp->nation)<<setw(8)<<(temp->address)<<setw(8)
<<(temp->nationality)<<setw(6)<<(temp->diploma)<<setw(9)<<(temp->birthday)<<setw(5)<<(temp->chinese)<<setw(5)<<(temp->English)
<<setw(5)<<(temp->math)<<setw(5)<<(temp->physics)<<endl;
if(temp->cell==head->cell) head=head->next;
}
}
/**
*析构函数,只用程序的正常结束才会执行改函数,并且把学生的信息保存到文件中
*/
Student::~Student()
{
Student*temp;
temp=new Student;
ofstream write_file;
write_file.open("stuinfo.txt",ios::beg);
if(!write_file)
{
cout<<"信息写入文件失败!"<<endl;
cout<<"按任意键退出.";
cin.get();
exit(0);
}
temp=head;
while(temp!=NULL)
{
write_file<<temp->cell<<" "<<temp->name<<" "<<temp->sex<<" "<<temp->nation<<" "<<temp->address<<" "<<temp->nationality<<" "<<
temp->diploma<<" "<<temp->birthday<<" "<<temp->chinese<<" "<<temp->English<<" "<<temp->math<<" "<<temp->physics<<endl;
temp=temp->next;
}
write_file<<0;
write_file.close();
}
/**
*主函数,主要提供一些菜单选项
*/
void main()
{
char select;
int selection;
Student student;
cout<<"\n○●○●○●○●○●○●○●○●○●○●○●○●○●○●○●○●○●○●○●○●"<<endl;
if(student.get_info()==0)
{
cout<<"文件中没有信息"<<endl;
cout<<"您想添加学生信息吗?(Y/N):";
cin>>select;
if(select=='y'||select=='Y')
student.add_info();
else exit(0);
}
cout<<" ________________________________"<<endl;
cout<<" |★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★|"<<endl;
cout<<" |☆| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|☆|"<<endl;
cout<<" |★| 学生信息选项如下 |★|"<<endl;
cout<<" |□|____________________________|□|"<<endl;
cout<<" |☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆|"<<endl;
cout<<" |□| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|□|"<<endl;
cout<<" |★| 输入 1 通过学号查询 |★|"<<endl;
cout<<" |☆| 输入 2 添加学生信息到文件 |☆|"<<endl;
cout<<" |★| 输入 3 从文件中删除信息 |★|"<<endl;
cout<<" |☆| 输入 4 浏览所有学生信息 |☆|"<<endl;
cout<<" |★| 输入任意键退出 |★|"<<endl;
cout<<" |☆|____________________________|☆|"<<endl;
cout<<" |★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★|"<<endl;
cout<<"  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄"<<endl;
cout<<"请输入选项:";
cin>>selection;
while(selection>=1&&selection<=4)
{
if(selection==1) student.search_info_cell();
if(selection==2) student.add_info();
if(selection==3) student.del_info();
if(selection==4) student.out_all_info();
cout<<" ________________________________"<<endl;
cout<<" |★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★|"<<endl;
cout<<" |☆| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|☆|"<<endl;
cout<<" |★| 学生信息选项如下 |★|"<<endl;
cout<<" |□|____________________________|□|"<<endl;
cout<<" |☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆|"<<endl;
cout<<" |□| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|□|"<<endl;
cout<<" |★| 输入 1 通过学号查询 |★|"<<endl;
cout<<" |☆| 输入 2 添加学生信息到文件 |☆|"<<endl;
cout<<" |★| 输入 3 从文件中删除信息 |★|"<<endl;
cout<<" |☆| 输入 4 浏览所有学生信息 |☆|"<<endl;
cout<<" |★| 输入任意键退出 |★|"<<endl;
cout<<" |☆|____________________________|☆|"<<endl;
cout<<" |★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★|"<<endl;
cout<<"  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄"<<endl;
cout<<"请输入选项:";
cin>>selection;
}
}

#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#define N 3
typedef struct z1
{
char no[11];
char name[15];
int score[N];
float sum;
float average;
int order;
struct z1 *next;
}STUDENT;
STUDENT *init();
STUDENT *create();
STUDENT *del(STUDENT *h);
void print(STUDENT *h);
void search1(STUDENT *h);
void search2(STUDENT *h);
STUDENT *insert(STUDENT *h);
void sort(STUDENT *h);
void save(STUDENT *h);
void tongji(STUDENT *h);
int menu_select();
STUDENT *load();
void inputs(char *prompt,char *s,int count);
STUDENT *load();
main()
{
int i;
STUDENT *head;
head=init();
for(;;)
{
switch(menu_select())
{
case 0:head=init();break;
case 1:head=create();break;
case 2:head=insert(head);break;
case 3:save(head);break;
case 4:print(head);break;
case 5:search1(head);break;
case 6:head=del(head);break;
case 7:sort(head);break;
case 8:tongji(head);break;
case 9:search2(head);break;
case 10:exit(0);
}
}
}
int menu_select()
{
char *menu[]={"************菜单************",
"0. 初始化链表",
"1. 输入学生成绩",
"2. 插入学生成绩",
"3. 保存学生记录",
"4. 显示学生记录",
"5. 按学号查找学生信息",
"6. 删除指定学号的学生信息",
"7. 按某一门课对学生成绩排序",
"8. 统计某门课程的学生成绩",
"9. 按姓名查找学生信息",
"10. 退出系统"};
char s[3];
int c,i;
for(i=0;i<=11;i++)
printf(" %s\n",menu[i]);
do
{
printf("\n请选择0~10中的某一个选项\n");
scanf("%s",s);
c=atoi(s);
}while(c<0||c>10);
return c;
}
STUDENT *init()
{
return NULL;
}
STUDENT *create()
{
int i;int s;
STUDENT *h=NULL,*info;
for(;;)
{
info=(STUDENT *)malloc(sizeof(STUDENT));
if(!info)
{
printf("\n内存不足");
return NULL;
}
inputs("输入学号:",info->no,11);
if(info->no[0]=='@')break;
inputs("输入姓名:",info->name,15);
printf("开始输入%d门课的成绩\n",N);
s=0;
for(i=0;i<N;i++)
{
do{
printf("第%d门分数:",i+1);
scanf("%d",&info->score[i]);
if(info->score[i]>100||info->score[i]<0)
printf("输入成绩错误,请重新输入:\n");
}while(info->score[i]>100||info->score[i]<0);
s=s+info->score[i];
}
info->sum=s;
info->average=(float)s/N;
info->order=0;
info->next=h;
h=info;
}
return h;
}
void inputs(char *prompt,char *s,int count)
{
char p[255];
do
{
printf(prompt);
scanf("%s",p);
if(strlen(p)>count)
printf("\n太长了!\n");
}while(strlen(p)>count);
strcpy(s,p);
}
void print(STUDENT *h)
{
int i=0;
STUDENT *p;
p=h;
printf("\n\n\n***********************学生***********************\n");
printf("|序号|学号 | 姓名 | 语文 | 英语 |数学 | 总分 |平均分 |名次 |\n");
printf("|---|-------|--------|----|----|----|------|------|---|\n");
while(p!=NULL)
{
i++;
printf("|%3d |%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",i,p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);
p=p->next;
}
printf("***********************end***********************\n");
}
STUDENT *del(STUDENT *h)
{
STUDENT *p,*q;
char s[11];
printf("请输入要删除的学生的学号\n");
scanf("%s",s);
q=p=h;
while(strcmp(p->no,s)&&p!=NULL)
{
q=p;
p=p->next;
}
if(p==NULL)
printf("\n链表中没有学号为%s的学生\n",s);
else
{
printf("\n\n\n***********************找到了***********************\n");
printf("|学号 | 姓名 | 语文 | 英语 | 数学 | 总分 | 平均分 | 名次 |\n");
printf("|----------|----------|----|----|----|------|------|---|\n");
printf("|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);
printf("***********************end***********************\n");
printf("请按任意键删除\n");
getchar();
if(p==h)
h=p->next;
else q->next=p->next;
free(p);
printf("\n已经删除学号为%s的学生\n",s);
printf("不要忘了保存数据\n");
}
return h;
}
void search1(STUDENT *h)
{
STUDENT *p;
char s[11];
printf("请输入你要查找的同学的学号\n");
scanf("%s",s);
p=h;
while(strcmp(p->no,s)&&p!=NULL)
p=p->next;
if(p==NULL)
printf("'n没有学号为%s的学生\n",s);
else
{
printf("\n\n\n***********************找到了***********************\n");
printf("|学号 | 姓名 | 语文 | 英语 | 数学 | 总分 | 平均分 | 名次 |\n");
printf("|----------|-----------|----|----|----|------|------|---|\n");
printf("|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);
printf("***********************end***********************\n");
}
}
void search2(STUDENT *h)
{
STUDENT *p;
char s[11];
printf("请输入你要查找的同学的姓名\n");
scanf("%s",s);
p=h;
while(strcmp(p->name,s)&&p!=NULL)
p=p->next;
if(p==NULL)
printf("\n没有姓名为%s的学生\n",s);
else
{
printf("\n\n\n***********************找到了***********************\n");
printf("|学号 | 姓名 | 语文 | 英语 | 数学 | 总分 | 平均分 | 名次 |\n");
printf("|----------|-----------|----|----|----|------|------|---|\n");
printf("|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);
printf("***********************end***********************\n");
}
}
STUDENT *insert(STUDENT *h)
{
STUDENT *p,*q,*info;
char s[11];
int s1,i;
printf("请输入插入点的学生学号\n");
scanf("%s",s);
printf("\n请输入新的学生信息\n");
info=(STUDENT *)malloc(sizeof(STUDENT));
if(!info)
{
printf("\n内存不足!");
return NULL;
}
inputs("输入学号:",info->no,11);
inputs("输入姓名:",info->name,15);
printf("请输入%d门课的分数\n",N);
s1=0;
for(i=0;i<N;i++)
{
do{
printf("分数%d",i+1);
scanf("%d",&info->score[i]);
if(info->score[i]>100||info->score[i]<0)
printf("输入数据有误,请重新输入\n");
}while(info->score[i]>100||info->score[i]<0);
s1=s1+info->score[i];
}
info->sum=s1;
info->average=(float)s1/N;
info->order=0;
info->next=NULL;
p=h;
q=h;
while(strcmp(p->no,s)&&p!=NULL)
{q=p;p=p->next;}
if(p==NULL)
if(p==h)
h=info;
else q->next=info;
else
if(p==h)
{
info->next=p;
h=info;
}
else
{
info->next=p;
q->next=info;
}
printf("\n已经插入了%s这个学生\n",info->name);
printf("----不要忘了存盘啊--\n");
return(h);
}
void save(STUDENT *h)
{
FILE *fp;
STUDENT *p;
char outfile[10];
printf("请输入保存文件的文件名,例如 c:\\f1\\te.txt:\n");
scanf("%s",outfile);
if((fp=fopen(outfile,"wb"))==NULL)
{
printf("不能打开文件\n");
exit(1);
}
printf("\n正在保存......\n");
p=h;
while(p!=NULL)
{
fwrite(p,sizeof(STUDENT),1,fp);
p=p->next;
}
fclose(fp);
printf("------保存成功!!!------\n");
}
void sort(STUDENT *h)
{
int i=0,j;
STUDENT *p,*q,*t,*h1;
printf("请输入要按哪门课程的编号来排序:(0.语文 1.数学 2.英语)\n");
scanf("%d",&j);
h1=h->next;
h->next=NULL;
while(h1!=NULL)
{
t=h1;
h1=h1->next;
p=h;
q=h;
while(t->score[j]<p->score[j]&&p!=NULL)
{
q=p;
p=p->next;
}
if(p==q)
{
t->next=p;
h=t;
}
else
{
t->next=p;
q->next=t;
}
}
p=h;
while(p!=NULL)
{
i++;
p->order=i;
p=p->next;
}
print(h);
printf("排序成功!!!\n");
}
void tongji(STUDENT *h)
{
STUDENT *p;
int a,b,i;
printf("请输入课程编号\n");
scanf("%d",&i);
printf("请输入分数段:\n");
scanf("%d,%d",&a,&b);
p=h;
while(p!=NULL)
{
printf("\n\n\n***********************找到了***********************\n");
if(p->score[i]>=a&&p->score[i]<=b)
{
printf("|学号 | 姓名 | 语文 | 英语 | 数学 | 总分 | 平均分 | 名次 |\n");
printf("|--------|---------|----|----|----|------|------|---|\n");
printf("|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);
}
p=p->next;
}
printf("***********************end***********************\n");
}

兄弟,这是要钱的,不是分就可以的

,加你,了

不会。


云和县19677936815: c语言 学生成绩管理系统设计学生成绩信息包括:学号,姓名,三门课程成绩(数学、英语和计算机)等.主要功能:(1) 计算各个学生的总分及平均分,... -
宥将壳脂:[答案] 希望对你有所帮助.#include"stdio.h"#include"stdlib.h"#include"string.h"#define N 3typedef struct z1{ char no[11]; char name[15]; int score[N]; float sum; float average; int order; ...

云和县19677936815: c语言课程设计之学生成绩管理系统设计的程序 -
宥将壳脂: #include#include#include #include#define MAX 80#define max 3int nu=0;struct classname{ char name[...

云和县19677936815: 怎么用c语言编写一个学生成绩管理系统啊?急…… -
宥将壳脂: C语言课程设计报告-------学生成绩简单管理程序 一、系统菜单的主要功能 (1)输入若干条记录 (2)显示所有记录 (3)按学号排序 (4)插入一条记录 (5)按姓名查找,删除一条记录 (6)查找并显示一条记录 (7)输出统计信息 (新增)...

云和县19677936815: c语言设计学生成绩管理系统 -
宥将壳脂: #include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<list> #include<cstring> #include<map> #include<set> #include<algorithm> #include<queue> using namespace std; int n; struct birth {int year,month,day; };struct ...

云和县19677936815: C语言课程设计 学生成绩管理系统 -
宥将壳脂: #include "stdio.h" #define N 10 struct student {char num[10]; char name[20]; float score[3]; float sum; float aver; }stu[N]; void main() { void count(struct student stu[]); void sort(struct student stu[]); void find(struct student stu[]); int i; float temp; for(i=0;i<...

云和县19677936815: c语言编写学生成绩管理系统 -
宥将壳脂: #include <stdio.h> void main() { /*输入资料*/ int student[5][4],i; for (i=0; i<=4; i++); scanf("%d,%d,%d \n",student[i][0],student[i][1],student[i][2],student[i][3]) /*平均分*/ for (i=0; i<=4; i++); printf("%f",(float)((student[i][1]+student[i][2]+student[i][3]...

云和县19677936815: 如何用C语言编写"学生成绩管理系统" -
宥将壳脂: #include<stdio.h> /*引用库函数*/ #include<stdlib.h> #include<ctype.h> #include<string.h> typedef struct /*定义结构体数组*/ { char num[10]; /*学号*/ char name[20]; /*姓名*/ int score; /*成绩*/ }Student; Student stu[80]; /*结构体数组变量*/ int ...

云和县19677936815: C语言编程 学生成绩管理系统 -
宥将壳脂: 这是我们大一时候课程设计做的,学生成绩管理系统,功能比楼主需要的稍多一些,你看一下,不需要的函数删掉它好了.#include<stdio.h> #include<malloc.h> #include<string.h>struct stu {long num;char name[20];float score1,score2,score...

云和县19677936815: 学生成绩管理程序设计C语言设计 -
宥将壳脂: #include"stdio.h" #include"stdlib.h" #include"string.h" #define N 3 typedef struct z1 { char no[11]; char name[15]; int score[N]; float sum; float average; int order; struct z1 *next; }STUDENT; STUDENT *init(); STUDENT *create(); STUDENT *...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网