c++实现学生成绩管理系统

作者&投稿:壤适 (若有异议请与网页底部的电邮联系)
用c++实现一个学生成绩管理系统~

现在几乎都不用MFC了,做管理系统都用 C# + .NET + SQL Server。

主体思路:用 Visual Studio 2008 作为编程环境,用 WinForm 拉控件开发用户界面,用 C# 连接数据库SQL Server 2008,然后通过 C# 程序代码对数据库进行操作。

具体这样做:
安装Visual Studio 2008,新建C#窗体应用程序,在工具栏里面有控件,拉到窗体里面,设计用户界面,具体什么控件有什么用,请参考有关 C# 的书籍。
安装SQL Server 2008,配置好所有东西之后,建立数据库,建立你所需要的表,建立表与表之间的关系(这里参考有关SQL Server的书籍),然后在C#窗体应用程序里面,建立与数据库的连接(参考C#连接数据库的资料),然后往每个控件里面添加代码,实现对数据库的操作(添加、删除、修改、查询)。

这是大概的思路,具体的请参考有关C#和SQL Server的资料,如果可以的话,最好看一下别人的源代码,这样有利于你对整个程序的把握。

改好了。
#include //#include using namespace std;typedef struct student {int num;char name[30];//应该是数组int score;struct student *next;}NODE;NODE *create();void print(NODE *);int main() {int x;NODE *head;// head = (NODE *)malloc(sizeof(NODE));// head->next = NULL;do {printf("学生信息管理系统

");printf("1、录入学生信息
");printf("2、查询学生信息
");printf("3、删除学生信息
");printf("4、学生信息排序
");printf("5、修改学生信息
");printf("6、插入新学生信息
");printf("7、打印学生信息
");printf("8、退出应用程序

");printf("请输入您的选择:");scanf("%d",&x);switch (x) {case 1 : head = create();print(head);break;case 2 :case 3 :case 4 :case 5 :case 6 : printf("此项功能待完善。
"); break;case 7 : print(head);break;case 8 : break;default: printf("对不起,没有这个选项!
");}//; 这个分号是什么作用?}while(x != 8);return 0;}NODE *create () {NODE *head,*p;int x;head = p = (NODE *)malloc(sizeof(NODE));printf("请输入您要录入的学生的学号(0结束) : ");scanf("%d",&x);while(x) {p->next = (NODE *)malloc(sizeof(NODE));p->next->num = x;printf("请输入该学生的姓名 : ");scanf("%s",p->next->name);printf("请输入该学生的总成绩 : ");scanf("%d",&p->next->score);p = p->next;printf("请输入您要录入的学生的学号(0结束) : ");scanf("%d",&x);}p->next = NULL;return head;}void print(NODE *head) {int m = 1;NODE *p = head->next;while(p) {printf("第%d个学生的学号为:%d姓名为:%s总成绩为:%d
",m++,p->num,p->name,p->score);p = p->next;}}

#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;
}
}

用C写的一个,基本符合要求,你可以改改用
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 4//使用预定义,便于随时修改

//定义结构体
struct student_type
{
char name[8];
char num[11];
char cla[20];
int score[3];//int类型的成绩数组
double ave;//平均分
};
//定义结构体类型的学生数组
student_type stud[SIZE];
student_type temp;

//保存文件
void save()
{
FILE *fp;
int i;

//如果打开不成功
if(( fp = fopen("score.txt", "wb")) == NULL )
{
printf("The file can't open!\n");
return;
}

//以结构体形式保存到文件之中
for( i = 0; i < SIZE; i++ )
if( fwrite( &stud[i], sizeof( struct student_type ), 1, fp ) != 1 )
{
printf("file write error!");
return;
}
fclose( fp );//关闭文件流
//显示文件保存成功
printf("\n\nThe file save success.\n\n");

}

//文件输出
void display()
{
FILE *fp;
int i;
//打开所保存的文件
fp = fopen("score.txt","rb");

printf("Now, read the file...\n");
printf("*****************Welcome to The Score Manage System****************\n");
printf("Name No. Class score1 score2 score3 ave\n");
printf("*******************************************************************\n");
//将文件中的结构体读取出来,并显示到屏幕
for( i = 0; i < SIZE; i++ )
{
fread(&stud[i], sizeof( student_type ), 1, fp );
printf("%-10s%10s%10s %8d %8d %8d %10.2f\n", stud[i].name, stud[i].num,
stud[i].cla, stud[i].score[0], stud[i].score[1], stud[i].score[2], stud[i].ave );
}

fclose( fp );//关闭文件
}

//读入各个成绩
void read()
{
int i;
double sum[SIZE] = {0};//总分数组初始化

for( i = 0; i < SIZE; i++ )
{
printf("Enter Name, No., Class, score1, score2 and score3:\n");
scanf("%s%s%s%d%d%d", stud[i].name, stud[i].num, stud[i].cla, &stud[i].score[0], &stud[i].score[1], &stud[i].score[2]);
sum[i] = stud[i].score[0] + stud[i].score[1] + stud[i].score[2];//求总分
stud[i].ave = sum[i] / 3;//求平均成绩
}
}

//插入数据元素
void Insert()
{
int i, t, n;
FILE *fp, *fp1;

printf("Please Enter the Information you Insert:\n");
printf("Name, Student ID, class, score1, score2, score3:\n");
//输入的变量临时存储在temp中
scanf("%s%s%s%d%d%d", temp.name, temp.num, temp.cla, &temp.score[0], &temp.score[1], &temp.score[2]);
temp.ave =( temp.score[0] + temp.score[1] + temp.score[2]) / 3.0;

//打开排序后的文件
if(( fp = fopen("sortScore.txt","r")) == NULL )
{
printf("The file can't epen.\n\n");
exit( 0 );
}

//输出原始数据
printf("\n\nThe original score is :\n");
printf("Name No. Class score1 score2 score3 ave\n");
printf("*******************************************************************\n");
for( i = 0; i < SIZE; i++ )
{
printf("%-10s%10s%10s %8d %8d %8d %10.2f\n", stud[i].name, stud[i].num,
stud[i].cla, stud[i].score[0], stud[i].score[1], stud[i].score[2], stud[i].ave );
}

//从最后一个开始判断,是否大于,因为要插入,最后要向后移动一个位置
n = i;
for( t = 0; stud[t].ave > temp.ave && t < n; t++ );

//找到不大于的位置
printf("Now:\n");
fp1 = fopen("InsertScore.txt","w");
//输出没有变的一部分信息
for( i = 0; i < t; i++ )
{
fwrite( &stud[i], sizeof( struct student_type), 1, fp1 );
printf("%-10s%10s%10s %8d %8d %8d %10.2f\n", stud[i].name, stud[i].num,
stud[i].cla, stud[i].score[0], stud[i].score[1], stud[i].score[2], stud[i].ave );
}

//输出要插入的信息
fwrite( &temp, sizeof( struct student_type ), 1, fp1 );
printf("%-10s%10s%10s %8d %8d %8d %10.2f\n", temp.name, temp.num,
temp.cla, temp.score[0], temp.score[1], temp.score[2], temp.ave );

//输出原来剩余一部分信息
for( i = t; i < n; i++ )
{
fwrite( &stud[i], sizeof( struct student_type), 1, fp1 );
printf("%-10s%10s%10s %8d %8d %8d %10.2f\n", stud[i].name, stud[i].num,
stud[i].cla, stud[i].score[0], stud[i].score[1], stud[i].score[2], stud[i].ave );
}
printf("\n");

//关闭文件流
fclose( fp1 );
fclose( fp );

}

//排序,按照平均分从大到小排序
void Sort()
{
FILE *fp1, *fp2;
int i,j;

//打开原来存储信息的文件
if(( fp1 = fopen("score.txt","rb")) == NULL )
{
printf("The file can't epen.\n\n");
exit( 0 );
}

//建立一个存储排序后的信息的文件
if(( fp2 = fopen("sortScore.txt","wb")) == NULL )
{
printf("The file write error.\n");
exit(0);
}

for( i = 0; i < SIZE; i++ )
if(fread(&stud[i], sizeof(struct student_type), 1, fp1 ) != 1 )
{
printf("file read error.");
exit(0);
}

//循环遍历比较
for( i = 0; i < SIZE; i++ )
{
for( j = i + 1; j < SIZE; j++ )
{
//交换
if( stud[i].ave < stud[j].ave )
{
temp = stud[i];
stud[i] = stud[j];
stud[j] = temp;

}
fwrite( &stud[i], sizeof( struct student_type ), 1, fp2 );
}

}
fclose( fp1 );
fclose( fp2 );

//直接输出排序后的文件
FILE *fp;
fp = fopen("sortScore.txt","rb");
printf("\n\nAfter sort, the score is :\n");
printf("Name No. Class score1 score2 score3 ave\n");
printf("*******************************************************************\n");
for( i = 0; i < SIZE; i++ )
{
printf("%-10s%10s%10s %8d %8d %8d %10.2f\n", stud[i].name, stud[i].num,
stud[i].cla, stud[i].score[0], stud[i].score[1], stud[i].score[2], stud[i].ave );
}

fclose(fp);

}

//删除指定信息,以姓名为关键字
void Delete()
{
FILE *fp;
int i, j, n, flag;

char name[10];

//打开添加后的文件
if( (fp = fopen("InsertScore.txt","rb")) == NULL )
{
printf("The file can't epen.\n\n");
exit( 0 );

}
//输出原始信息
printf("\n\nThe original score is :\n");
printf("Name No. Class score1 score2 score3 ave\n");
printf("*******************************************************************\n");
for( i = 0; fread(&stud[i], sizeof( struct student_type), 1, fp) != 0; i++ )
{
printf("%-10s%10s%10s %8d %8d %8d %10.2f\n", stud[i].name, stud[i].num,
stud[i].cla, stud[i].score[0], stud[i].score[1], stud[i].score[2], stud[i].ave );
}
fclose( fp );

n = i;

//输入要删除的姓名
printf("\nEnter the name you delete:");
scanf("%s", name );

for( flag = 1, i = 0; flag && i < n; i++ )
{
if( strcmp( name, stud[i].name ) == 0 )
{
//如果找到该位置,将后面的依次向前移动一个位置
for( j = i; j < n - 1; j++ )
{
strcpy( stud[j].name, stud[j+1].name );
strcpy( stud[j].cla, stud[j+1].cla );
strcpy( stud[j].num, stud[j+1].num );
stud[j].ave = stud[j+1].ave;
stud[j].score[0] = stud[j+1].score[0];

stud[j].score[1] = stud[j+1].score[1];
stud[j].score[2] = stud[j+1].score[2];
}
flag = 0;
}
}

if( !flag )
n = n - 1;
else
printf("\nCan't found!\n");

//输出删除后的信息
printf("Now ,the socre are:\n");
if((fp = fopen("AfterDelete.txt","wb")) == NULL )
{
printf("Can't open file!\n");
exit(0);
}
for( i = 0; i < n; i++ )
fwrite(&stud[i], sizeof( struct student_type), 1, fp);

fclose(fp);

fp = fopen("AfterDelete.txt","r");
for( i = 0; fread( &stud[i], sizeof(struct student_type), 1, fp ) != 0; i++)
{
printf("%-10s%10s%10s %8d %8d %8d %10.2f\n", stud[i].name, stud[i].num,
stud[i].cla, stud[i].score[0], stud[i].score[1], stud[i].score[2], stud[i].ave );

}

printf("\n");
fclose(fp);

}

void main()
{
int choice;

printf("\t~~Welcome to the score Manage System~~\n");
printf("Enter you choice:\n");
printf("1, Add 2, sort 3, Insert 4, Delete 0 exit \n");

scanf("%d", &choice );

while( choice != 0 )
{
switch( choice )
{
case 1:read();save();display();break;
case 2:Sort();break;
case 3:Insert();break;
case 4:Delete();break;
default:printf("Enter error.");
break;
}

printf("Enter you choice:\n");
printf("1, Add 2, sort 3, Insert 4, Delete 0 exit \n");
scanf("%d", &choice );
}

}

/*测试数据,直接拷贝,粘贴
Angle 48140623 0623 95 98 97
Lucy 48140624 0624 95 65 78
Mark 48140625 0625 99 100 85
Tom 48140626 0626 45 65 85
*/

在大学生计算机网


使用C语言做一个学生成绩管理系统
题描述用C语言编写一个程序实现学生成绩管理,每个学生包括3门课的成绩,从键盘输入学生信息,包括学号、姓名、三门课成绩,计算出学生的平均成绩,按照学生平均成绩由大到小... 题描述 用C语言编写一个程序实现学生成绩管理,每个学生包括3门课的成绩,从键盘输入学生信息,包括学号、姓名、三门课成绩,计算出学生...

C语言编程:学生成绩管理系统
3,数据的输入和输出模块:要求学生的一门课的成绩是一个综合成绩,有三部分组成:平时成绩占10%,实验成绩占20%,和考试成绩占70%,所以设计输入函数时,输入的是该门课程的平均成绩,实验成绩和考试成绩,通过运算最后得到该门课程的综合成绩。输入和输出的学生信息至少包括学生的学号,学生的姓名,成绩等。4,成绩统计模块...

c语言的学生成绩管理系统
1、写一个“学生成绩管理”程序,要求程序如下功能:(1)成绩录入,(2)成绩修改(按学号修改),(3)成绩查询(至少提供按学号、按姓名、按班级、按课程等4种查询方式)(4)统计... 1、 写一个“学生成绩管理”程序,要求程序如下功能: (1) 成绩录入,(2)成绩修改(按学号修改),(3)成绩查询(至少提供按学号、按姓名...

用C语言做学生成绩管理软件
一、主要内容用C语言为教学管理人员编写一个学生成绩管理软件。对学生的成绩信息进行管理,学生信息包括:学号、姓名、学期、每门课程的成绩、平均成绩、名次。实现:学生信息的录入;... 一、主要内容用C语言为教学管理人员编写一个学生成绩管理软件。对学生的成绩信息进行管理,学生信息包括:学号、姓名、学期、每门课程...

用C语言编程实现一个简单的学生成绩管理系统
\/\/姓名,学号,英语,语文,数学三种成绩#include <stdio.h>#include <stdlib.h>#define maxnumber 30int student_number;int count1=0,count2=0,Operate1=3;FILE *stream;typedef struct stu{ int idnumber; char name[20]; double English_score; double chinese_score; double math_score;}...

求以下c语言编程:一个简单的学生成绩管理系统。其中每个学生信息包括学 ...
一个简单的学生成绩管理系统。其中每个学生信息包括学号、姓名、数学成绩、英语成绩、计算机成绩。编写一个菜单程序分别完成以下功能:每个学生的信息使用结构体变量存储。编写函数fu... 一个简单的学生成绩管理系统。其中每个学生信息包括学号、姓名、数学成绩、英语成绩、计算机成绩。编写一个菜单程序分别完成以下功能:每个...

用C语言编程实现一个简单的学生成绩管理系统
include <stdio.h>#include <stdlib.h>#include <string.h>#include<memory.h>typedef struct student{char num[16];char name[20];float score[4];struct student *next;} stu;stu *head; \/\/ 链头指针stu* create()\/\/ 创建链表,从文件读取信息 { printf("Reading student information...

c语言实现设计一个学生成绩管理系统课程
我快不行了QAQ求大神助攻QAQC语言实现为某学校日常学生成绩管理设计一个学生成绩管理系统:1、设计学生成绩管理文件结构,编程实现学生成绩信息输入。2、实现按学号进行学生成绩的修改... 我快不行了QAQ求大神助攻QAQC语言实现为某学校日常学生成绩管理设计一个学生成绩管理系统:1、设计学生成绩管理文件结构,编程实现学生...

C语言编写学生成绩管理系统。。。高分求助!!!
include <stdio.h> include <io.h> include <stdlib.h> include <string.h> define MAX 200 struct student { char no[10]; \/\/ 学号 char name[50]; \/\/ 姓名 int sum; \/\/ 次数 float score; \/\/ 分数 };struct data { int count; \/\/ 当前学生数组中学生的个数 struc...

急求C 学生成绩管理系统
设计题目:学生成绩管理功能要求:程序应完成成绩录入,查询,统计,排序,插入,删除等功能。并实现菜单设计,使用数据文件保存和修改,应用结构体和指针等内容。...  设计题目:学生成绩管理 功能要求:程序应完成成绩录入,查询,统计,排序,插入,删除等功能。并实现菜单设计,使用数据文件保存和修改, 应用...

祁门县15272527707: 用C++求学生成绩管理系统 -
望炒牛黄: 学生成绩管理系统-c语言程序代码二 学生成绩管理系统-c语言版 #include "stdio.h" /*I/O函数*/ #include "stdlib.h" /*其它说明*/ #include "string.h" /*字符串函数*/ #include "conio.h" /*屏幕操作函数*/ #include "mem.h" /*内存操作函数*/ ...

祁门县15272527707: 用C++编写一个学生成绩管理系统!急!!! -
望炒牛黄: #include<stdio.h>#include<stdlib.h>#include<string.h>#define N 50 /*定义符号常量,代表学生人数最大值*/ int count=0; /*全局变量,用于记录数组的当前位置*/ struct student /*定义结构体类型,代表学生信息*/ { char name[9]; /*学生姓名*/ char ...

祁门县15272527707: c++程序设计,,,,,学生成绩管理系统
望炒牛黄: #include<vector> #include<iostream> #include<string> #include<sstream> #include<algorithm> using namespace std; struct student { string num; int score[4]; float ave; int tot; }; typedef vector<student>::iterator iter; void in(vector<student> &vec) { ...

祁门县15272527707: 求一个学生成绩管理系统(C++)
望炒牛黄: #ifndef _CLASS_H#define _CLASS_H #include"Student.h"#include"ArrayList.h"#include"Sort.h"#include"Search.h"#include"Insert.h"#include"Modify.h"#include"Delete.h"#include<fstream> using namespace std;const int NUM...

祁门县15272527707: 学生成绩管理系统 C++源代码
望炒牛黄: 添加一个数据库,再写如下代码 Private Sub Combo1_Click() Data1.RecordSource = Combo1.Text Data1.Refresh Text1.DataField = Data1.Recordset.Fields(0).Name Text2.DataField = Data1.Recordset.Fields(1).Name Text3.DataField = Data1....

祁门县15272527707: C++编程写一个学生成绩管理系统 -
望炒牛黄: #include#includestruct STUDENTINFO { long nID; char cName[30]; float fscore[5]; }; //输入学生信息 void inputStudentInfo(struct STUDENTINFO *info,int n); //冒泡排序法,当然还有其他的排序法 void sortInfo(struct STUDENTINFO *info,int n)...

祁门县15272527707: C++编写学生成绩管理系统
望炒牛黄: //大概结构,其他什么东西,自己写,什么属性自己加. #include<iostream> #include<string> using namespace std; struct Student { string name; double gra1; double gra2; double gra3; double ave; int t;//标志是不是被删除的. }; Student stu[100]...

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