c大作业学生信息管理系统源代码

合集下载

c语言学生管理系统代码

c语言学生管理系统代码

C语言学生管理系统代码
简介
学生管理系统是一个用于管理学生信息的简单程序,它可以实现添加学生信息、显示学生信息、修改学生信息和删除学生信息等功能。

通过这个系统,学校或机构可以更方便地管理和维护学生的相关数据。

功能
1.添加学生信息:通过输入学生的姓名、学号、年龄和性别等信息,将
学生信息存储在系统中。

每个学生信息包括学号、姓名、年龄和性别等关键信息。

2.显示学生信息:可以显示系统中所有学生的信息,包括学号、姓名、
年龄和性别。

3.修改学生信息:通过输入学生的学号,可以修改该学生的姓名、年龄
和性别等信息。

4.删除学生信息:通过输入学生的学号,可以删除该学生的信息。

实现
下面是一个简单的C语言学生管理系统代码示例:
```c #include <stdio.h> #include <string.h>
#define MAX_STUDENTS 100
// 定义学生结构体 struct Student { int id; char name[100]; int age; char
gender[10]; };
// 定义全局变量,用于存储学生信息和统计学生数量 struct Student
students[MAX_STUDENTS]; int num_students = 0;
// 添加学生 void addStudent() { if (num_students >= MAX_STUDENTS) { printf(。

学生管理系统c语言源代码

学生管理系统c语言源代码

int main()
{
initLinkTable(&head);//初始化表头
readStu();//读入源文件
while (1)
{
menu();
system("cls");
}
}
void initLinkTable(studentLinkPoint *p)
int sum(studentLinkPoint);//求和
void avg(studentLinkPoint);//求平均分
void disAvgSum(studentLinkPoint);//显示总分和平均分
char *inputNumber();//专门用来输入一个学生的学号,返回该字符串的指针
char name[20];
char number[18];
int i;
if(temp==0)
{
error("input");
return 0;
}
else
{
temp->student=(studentPint)malloc(sizeof(studentNod));
break;
case 0:
del(head,end);
break;
}
if(c==0)
exit(1);
}
void del(studentLinkPoint p,studentLinkPoint End)
{
studentLinkPoint q;
if(end==head)
printf(" %3.1f %3.1f\n",p->student->sum,p->student->avg);

C语言大作业——学生成绩管理系统v2.0

C语言大作业——学生成绩管理系统v2.0

//成绩管理系统v2.0#include <stdio.h>#include <stdlib.h>#define N 30void Input (long num[],int score[],int n);void Totalave (int score[],int n);void Scoredes (long num[],int score[],int n,int (*compare)(int a,int b)); int Ascending (int a,int b);void Numas (long num[],int score[],int n);void Search (long num[],int score[],int n,int x);void statistis (long num[],int score[],int n);void List (long num[],int score[],int n);int main(){int n,score[N],c,x,i;long num[N];printf("输入学生人数");scanf("%d",&n);printf("1.Input record\n");printf("2.Caculate totel and average score of course\n");printf("3.Sort in descending order by score\n");printf("4.Sort in ascending order by number\n");printf("5.Search by number\n");printf("6.Statistic analysis\n");printf("7.List record\n");printf("0.Exit\n");printf("Please enter your choice:\n");printf("\n");for(;;){scanf("%d",&c);switch(c){case 1:Input (num,score,n);printf("Please enter your choice:\n");break;case 2:Totalave (score,n);printf("Please enter your choice:\n");break;case 3:Scoredes (num,score,n,Ascending);for(i=0;i<n;i++)printf("ID:%10ld,score:%d\n",num[i],score[i]);//以长整形打印用%ld printf("Please enter your choice:\n");break;case 4:Numas (num,score,n);printf("Please enter your choice:\n");break;case 5:printf("请输入查找学号\n");scanf("%d",&x);Search (num,score,n,x);printf("Please enter your choice:\n");break;case 6:statistis (num,score,n);printf("Please enter your choice:\n");break;case 7:List (num,score,n);Totalave (score,n);printf("Please enter your choice:\n");break;case 0:exit(0);}}return 0;}void Input (long num[],int score[],int n){int i;for(i=0;i<n;i++){printf("Input student's ID and score");scanf("%ld%d",&num[i],&score[i]);}}void Totalave (int score[],int n){int i,sum=0;double ave;for(i=0;i<n;i++)sum=sum+score[i];ave=(double)sum/n;printf("Caculate total=%d,average score of course=%f\n",sum,ave); }void Scoredes (long num[],int score[],int n,int(*compare)(int a,int b)){int i,j,k,t,h;for(i=0;i<n;i++){k=i;for(j=i+1;j<n;j++){if ((*compare)(score[j],score[k]))k=j;}if(i!=k){t=score[k],h=num[k];score[k]=score[i],num[k]=num[i];score[i]=t,num[i]=h;}}}int Ascending (int a,int b){return a<b;}void Numas (long num[],int score[],int n){int i,j,k,t,h;for(i=0;i<n;i++){k=i;for(j=i+1;j<n;j++){if (num[j]<num[k])k=j;}if(i!=k){t=score[k],h=num[k];score[k]=score[i],num[k]=num[i];score[i]=t,num[i]=h;}}for(i=0;i<n;i++)printf("ID:%10ld,score:%d\n",num[i],score[i]);//以长整形打印用%ld }void Search (long num[],int score[],int n,int x){int high=n-1,low=0,mid,c=0,pos,find=0,i,j,k,t,h;for(i=0;i<n;i++){k=i;for(j=i+1;j<n;j++){if (num[j]<num[k])k=j;}if(i!=k){t=score[k],h=num[k];score[k]=score[i],num[k]=num[i];score[i]=t,num[i]=h;}}while(find==0&&low<=high){mid=(high+low)/2;if(x>num[mid])low=mid+1;else if(x<num[mid])high=mid-1;else{pos=mid;find=1;}}if(find==0)printf("not find\n");else{for(i=0;i<n;i++){if(score[i]>score[pos])c++;}printf("ID:%10ld,order:%d,score:%d\n",num[pos],c+1,score[pos]);}}void statistis (long num[],int score[],int n){int a=0,b=0,c=0,d=0,e=0,i;double A,B,C,D,E;for(i=0;i<n;i++){if(score[i]>=90)a++;else if(score[i]>=80)b++;else if(score[i]>=70)c++;else if(score[i]>=60)d++;elsee++;}A=(double)a/n*100;B=(double)b/n*100;C=(double)c/n*100;D=(double)d/n*100;E=(double)e/n*100;printf("优秀人数%d,百分比:%f%%\n",a,A);printf("良好人数%d,百分比:%f%%\n",b,B);printf("中等人数%d,百分比:%f%%\n",c,C);printf("及格人数%d,百分比:%f%%\n",d,D);printf("不及格人数%d,百分比:%f%%\n",e,E); }void List (long num[],int score[],int n){int i;for(i=0;i<n;i++){printf("ID:%10ld,score:%d\n",num[i],score[i]);}}。

c语言管理系统设计源代码

c语言管理系统设计源代码

c语言管理系统设计源代码以下是一个简单的C语言管理系统示例,用于管理学生信息。

该系统可以添加、删除、修改和查找学生信息。

c复制代码#include<stdio.h>#include<stdlib.h>#include<string.h>struct student {char name[50];int roll;float marks;};struct student students[100];int count = 0;void add_student() {struct student new_student;printf("Enter name: ");scanf("%s", new_);printf("Enter roll number: ");scanf("%d", &new_student.roll);printf("Enter marks: ");scanf("%f", &new_student.marks);students[count] = new_student;count++;}void delete_student() {int index;printf("Enter index of student to delete: ");scanf("%d", &index);for (int i = index; i < count - 1; i++) {students[i] = students[i + 1];}count--;}void modify_student() {int index;struct student new_student;printf("Enter index of student to modify: "); scanf("%d", &index);printf("Enter new name: ");scanf("%s", new_);printf("Enter new roll number: ");scanf("%d", &new_student.roll);printf("Enter new marks: ");scanf("%f", &new_student.marks);students[index] = new_student;}void find_student() {char name[50];printf("Enter name of student to find: "); scanf("%s", name);for (int i = 0; i < count; i++) {if (strcmp(students[i].name, name) == 0) { printf("Roll number: %d\n", students[i].roll); printf("Marks: %.2f\n", students[i].marks); return;}}printf("Student not found.\n");}int main() {int choice;do {printf("\nMenu:\n");printf("1. Add student\n");printf("2. Delete student\n");printf("3. Modify student\n");printf("4. Find student\n");printf("5. Exit\n");printf("Enter choice: ");scanf("%d", &choice);switch (choice) {case1: add_student(); break;case2: delete_student(); break;case3: modify_student(); break;case4: find_student(); break;case5: exit(0); break; // exit the program here, otherwise the loop will keep running indefinitely, as it is in the do-while loop above. We are not returning, but rather exiting the program completely, so we do not need to return anything. The return value of main is always 0, and this is how the program exits. If you want to return a value other than 0, you can do so like this: return 1; or return -1; or return any other integer value you want to represent an error condition. The operating system will interpret this as the program's exit status. In this case, it will be seen as successful, as it is returning 0. The return value of main is not used for anything in this program, but it can be used in other programs to determine whether the program exited successfully or with an error. For example, if you were writing a shell script that executed this program and needed to know if it was successful or not, you could check the return value of the program and act accordingly. This is a common practice in programming, and it is important to understand how it works so that you can use it effectively in your own programs.。

学生管理系统C代码

学生管理系统C代码
#define FILENAME "workers.db"/*定义数据库文件名为workers.db*/
int a=0;/*全局参数变量*/
struct workers/*建立结构体*/
{ ห้องสมุดไป่ตู้
int id;/*学生号*/
char name[10];/*姓名*/
char sex[10];/*性别*/
scanf("%d",&id);
if (head==NULL)
{
printf ("没有任何可供修改的档案\n按任意键返回主菜单...");
getch();
return 0;;
}
p3=head;
while (id!=p3->id&&p3->next!=NULL)
};
struct workers *head,*p,*p1;/*建立指针结构体*/
void output(struct workers *px)/*将输出信息分类,方便调用*/
{
printf ("学生号:%d\t姓名:%s\t性别:%s\t年龄:%s\n学历:%s\t工资:%s\t地址:%s\t电话:%s\n",px->id,px->name,px->sex,px->age,px->level,px->wages,px->add,px->call);
}
goto start;
}
int savefile(void)/*保存文件*/
{
FILE *fp;
struct workers *p5;

C语言学生信息管理系统(源代码)

C语言学生信息管理系统(源代码)

#include <stdio.h>#include <string.h>/* 谭法建立单链表和输出单链表*/#include <malloc.h>#include <stdlib.h>typedef struct node{ int num;char name[20];struct node *next;}STD;#define LEN sizeof(STD)int menu_select();void handle_menu1();void game4();void game2();STD *insert(STD *head,STD *stud);STD *insert2(STD *head,STD *stud); void game3();void game5();STD *delete(STD*head,long num);void game1();void game6();STD *search(STD*head,long num);STD *head1,*head2;int n=0;/*追加法建表*/void creat1(void){ STD *p1,*p2;system("CLS");head1=NULL;p1=(STD *)malloc(LEN);p2=p1;printf("建表方法1追加法建表!\n");printf("输入学号姓名,若输入学号为0则退出建表!\n");scanf("%d%s",&p1->num,p1->name);while(p1->num!=0){ n++;if(n==1)head1=p1;elsep2->next=p1;p2=p1;p1=(STD *)malloc(LEN);scanf("%d%s",&p1->num,p1->name);}free(p1); p2->next=NULL;scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");return ;}/* 插入法建表*/void creat2(void){ STD *p1;head2=NULL;system("CLS");p1=(STD *)malloc(LEN);printf("建表方法2插入法建表!\n");printf("输入学号姓名(输入学号以0结束)!\n");scanf("%d%s",&p1->num,p1->name);while(p1->num!=0){ p1->next=head2;head2=p1;p1=(STD *)malloc(LEN);scanf("%d%s",&p1->num,p1->name);}scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");free(p1);return ;}/* 链表输出*/void print(STD *head){ STD *p;p=head;while (p!=NULL){ printf("学号%3d 姓名%s\n",p->num,p->name); p=p->next;} printf("链表为空!\n");scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");}/*-------------------------------------------------*//*--------------表1插入结点函数-------*//*-------------------------------------------------*/void game4(){char ch;STD *stud,*head=head1;system("CLS");printf("\t仅限在表1中插入!\n");printf("\t输入要插入结点的学号和姓名(以空格隔开):");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);if(stud->num<0){ printf("\t输入的学号不能为负数,请重新选择插入!\n");return;}while(stud->num>=0){head1=insert(head,stud);printf("\t继续插入新结点吗?(y/n):");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入新结点学号姓名:(输入n结束插入)");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2插入结点函数-------*//*-------------------------------------------------*/void game2(){char ch;STD *stud,*head=head2;system("CLS");printf("\t仅限在表2中插入!\n");printf("\t输入要插入结点的学号和姓名(以空格隔开):");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);if(stud->num<0){ printf("\t输入的学号不能为负数,请重新选择插入!\n");return;}while(stud->num>=0){head2=insert2(head,stud);printf("\t继续插入新结点吗?(y/n):");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入新结点学号姓名:(输入n结束插入)");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 插入模块*//**************************************/STD *insert(STD *head,STD *stud){STD *p0,*p1,*p2;p1=head;p0=stud;if(head==NULL){head=p0;p0->next=NULL;}else{while((p0->num>p1->num)&&(p1->next!=NULL)){p2=p1; p1=p1->next;}if(p0->num<=p1->num){if(head==p1)head=p0;else p2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}n=n+1;printf("按回车键继续!\n");getchar();system("CLS");return (head);}/**************************************//* 插入模块2 *//**************************************/STD *insert2(STD *head,STD *stud){STD *p0,*p1,*p2;p1=head;p0=stud;if(head==NULL){head=p0;p0->next=NULL;}else{while((p0->num<p1->num)&&(p1->next!=NULL)){p2=p1; p1=p1->next;}if(p0->num>=p1->num){if(head==p1)head=p0;else p2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}n=n+1;printf("按回车键继续!\n");getchar();system("CLS");return (head);}/*-------------------------------------------------*//*--------------表1删除学生信息-------*//*-------------------------------------------------*/void game3(){ int num;char ch;STD *head=head1;printf("\t仅限在表1中删除!\n");printf("\t输入要删除的学号:");scanf("%*c");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新选择删除!\n");return;}while(num>=0){head=head1;head1=delete(head,num);printf("\t继续删除吗?(y/n):");scanf("%*c");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要删除的学号:(输入n结束删除!)");scanf("%*c");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2删除学生信息-------*//*-------------------------------------------------*/void game5(){ int num;char ch;STD *head=head2;printf("\t仅限在表2中删除!\n");printf("\t输入要删除的学号:");scanf("%*c");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新选择删除!\n");return;}while(num>=0){head=head2;head2=delete(head,num);printf("\t继续删除吗?(y/n):");scanf("%*c");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要删除的学号:(输入n结束删除!)");scanf("%*c");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 删除模块*//**************************************/STD *delete(STD*head,long num){STD *p1,*p2;if (head==NULL) {printf("\n没有找到该学号!\n");return head;} p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num){if(p1==head)head=p1->next;else p2->next=p1->next;printf("\n删除:%ld\n",num);n=n-1;}elseprintf("\n 没有发现此项! \n",num);system("CLS");return(head);}/*-------------------------------------------------*//*--------------表1查找学生信息-------*//*-------------------------------------------------*/void game1(){ int num;char ch;STD *head=head1;printf("\t仅限在表1中查找!\n");printf("\t输入要查找的学号:");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新查找!\n");return;}while(num>=0){head=head1;head1=search(head,num);printf("\t继续查找吗?(y/n):");scanf("%d",&num);ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要查找的学号:(输入n结束查找)");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2查找学生信息-------*//*-------------------------------------------------*/void game6(){ int num;char ch;STD *head=head2;printf("\t仅限在表2中查找!\n");printf("\t输入要查找的学号:");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新查找!\n");return;}while(num>=0){head=head2;head2=search(head,num);printf("\t继续查找吗?(y/n):");scanf("%d",&num);ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要查找的学号:(输入n结束查找)");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 查找模块*//**************************************/STD *search(STD*head,long num){STD *p1,*p2;if (head==NULL) {printf("\n没有找到该学号!\n");return head;} p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num)printf("\n%d %s\n",p1->num,p1->name);elseprintf("\n 没有发现此项! \n",num);return(head);}/* void main(){printf(" *** 运行结果***\n");printf("输入学号姓名(输入学号以0结束)!\n");creat1();print(head1);creat2();print(head2);} *///******************************//* select.cpp:主程序文件*//******************************void main(){handle_menu1();}//*****************************//* 菜单处理函数*//*****************************void handle_menu1(){int h;for(;;){h=menu_select();switch(h){ case 1:/* printf("\t进入追加法建表\n"); */creat1();break; /* 调用功能模块*/case 2:/* printf("\t进入插入法建表\n"); */creat2();break;case 3:/* printf("\t输出追加法链表的结果\n"); */print(head1);break;case 4:/* printf("\t输出插入法链表的结果\n"); */print(head2);break;case 5:/* printf("\t链表1插入\n"); */game4();break;case 6:/* printf("\t链表2插入\n"); */game2();break;case 7:/* printf("\t链表1删除\n"); */game3();break;case 8:/* printf("\t链表2删除\n"); */game5();break;case 9:/* printf("\t链表1查找\n"); */game1();break;case 10:/* printf("\t链表2查找\n"); */game6();break;case 11:printf("\t再见,欢迎再次使用本系统!谢谢!\n");return;}}}//**********************************//* 菜单选择函数: int menu_select()*//**********************************int menu_select(){int cn;for(;;){printf("\ \n");printf("\t1.追加法建表\n");printf("\ \n");printf("\t2.插入法建表\n");printf("\ \n");printf("\t3.输出链表1\n");printf("\ \n");printf("\t4.输出链表2\n");printf("\ \n");printf("\t5.插入链表1 \n");printf("\ \n");printf("\t6.插入链表2 \n");printf("\ \n");printf("\t7.删除链表1 \n");printf("\ \n");printf("\t8.删除链表2 \n");printf("\ \n");printf("\t9.查找链表1 \n");printf("\ \n");printf("\t10.查找链表2 \n");printf("\ \n");printf("\t11.退出系统\n");printf("\ \n");printf("\t请您选择1-11:");scanf("%d",&cn);//gets(s);//cn=atoi(s);if(cn<1||cn>11)printf("\n\t输入错误,重选1-11:");elsebreak;}return cn;}。

学生信息管理系统源代码

学生信息管理系统源代码

#include<stdio.h>#include <stdlib.h>#include <string.h>typedef struct{long class_1; //班级long number; //学号char name[20]; //姓名float math; //数学float c_program; //C语言float physics; //大学物理float english; //大学英语float polity; //政治float sport; //体育float summary; //总分float average; //平均分}Student;Student stud[100]; //定义结构体数组变量的大小int i=0; //i用于记录输入的学生的个数int menu() //菜单函数{int a;printf("***********************学生信息管理系统*************************\n");//菜单选择printf("\t\t【1】输入学生信息\n");printf("\t\t【2】显示所有学生的信息\n");printf("\t\t【3】按平均分升降排序\n");printf("\t\t【4】根据学生的学号查找学生的信息\n");printf("\t\t【5】插入学生的信息\n");printf("\t\t【6】删除学生的信息\n");printf("\t\t【7】修改学生的信息\n");printf("\t\t【8】从文件中读入数据\n");printf("\t\t【9】将所有记录写入文件\n");printf("\t\t【0】退出本系统\n");printf("***********************学生信息管理系统*************************\n");printf("请选择你要的操作【0-9】:");scanf("%d",&a); //读入一个数while(a<0 || a>9){printf("输入错误!请重新输入。

学生信息管理系统C语言源代码

学生信息管理系统C语言源代码

#include<stdio.h>#include<malloc.h>#include<string.h>#include<stdlib.h>#define len sizeof(struct student)FILE *fp;struct student{long num;char name[15];int age;char sex[3];char chushen[10];char dizhi[20];char phone[11];char email[20];struct student *next;};void menu(){printf("===========学生信息管理系统==========\n\n");printf(" 1、录入学生信息\n");printf(" 2、浏览学生信息\n");printf(" 3、查询学生信息\n");printf(" 4、删除学生信息\n");printf(" 5、插入学生信息\n");printf(" 6、修改学生信息\n");printf(" 7、排序学生信息\n");printf(" 8、退出管理系统\n");printf("=====================================\n");}struct student *creat() //录入学生信息{int n;struct student *head;struct student *p1,*p2;n=0;p1=p2=(struct student *) malloc(len);scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p1->num,&p1->age,p1->name,p1->sex,p1->chushen ,p1->dizhi,p1->phone,p1->email);head=NULL;while(p1->num!=0){n=n+1;if(n==1) head=p1;else p2->next=p1;p2=p1;p1=(struct student *)malloc(len);scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p1->num,&p1->age,p1->name,p1->sex,p1->chu shen,p1->dizhi,p1->phone,p1->email);}p2->next=NULL;return(head);}void insert(struct student *head) //插入学生信息{int search_num;struct student *p,*q,*s;p=head;printf("在哪个学生前插入请输入学号:\n");scanf("%d",&search_num);while((p!=NULL)&&(p->num!=search_num)){q=p;p=p->next;}s=(struct student *)malloc(len);q->next=s;system("cls");printf("请输入学生信息:\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&s->num,&s->age,s->name,s->sex,s->chushen,s->diz hi,s->phone,s->email);s->next=p;}void printList(struct student *head) //浏览全部学生信息{struct student *p;p=head;if(head==NULL)printf("没有学生信息!!\n");else{do{fread(p,len,1,fp);printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->diz hi,p->phone,p->email);p=p->next;}while(p!=NULL);}}void findList_num(struct student *head,long search_num) //按学号查找{struct student *p;p=head;while((p!=NULL)&&(p->num!=search_num))p=p->next;if(p!=NULL)printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->diz hi,p->phone,p->email);elseprintf("没有该学生信息!!\n");}void findList_name(struct student *head,char *search_name) //按姓名查找{struct student *p;int cmp1=0,cmp=0;p=head;while(p!=NULL)if(strcmp(p->name,search_name)!=0){p=p->next;cmp++;}else{printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->dizhi,p->phone,p->email);p=p->next;cmp1=1;}if(cmp!=0&&cmp1==0)printf("没有该学生信息!!\n");}void xiugai(struct student *p1,long xiu_num) //修改学生信息{struct student *p2;p2=p1;while((p2!=NULL)&&(p2->num!=xiu_num))p2=p2->next;if(p2!=NULL){scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p2->num,&p2->age,p2->name,p2->sex,p2->chu shen,p2->dizhi,p2->phone,p2->email);}elseprintf("没有该学生信息!!\n");}struct student *delList(struct student *head,long del_num) // 删除学生信息{struct student *p,*q;p=head;q=head;while(p &&(p->num != del_num)){q=p;p=p->next;}if(p==NULL)printf("无此学号!\n");else{if(p == head){head = p->next;free(p);}else{q->next = p->next;free(p);}}return head;}void paixu(struct student *head) //按学号排序{struct student *p,*f,*t;char ch[100];int i;t=f=p=head;for(p=head;p->next!=NULL;p=p->next){for(t=head,f=t->next;t->next!=NULL;t=t->next,f=f->next){if(t->num>f->num>0){i=t->num;t->num=f->num;f->num=i;i=t->age;t->age=f->age;f->age=i;strcpy(ch,t->name);strcpy(t->name,f->name);strcpy(f->name,ch);strcpy(ch,t->sex);strcpy(t->sex,f->sex);strcpy(f->sex,ch);strcpy(ch,t->chushen);strcpy(t->chushen,f->chushen);strcpy(f->chushen,ch);strcpy(ch,t->dizhi);strcpy(t->dizhi,f->dizhi);strcpy(f->dizhi,ch);strcpy(ch,t->phone);strcpy(t->phone,f->phone);strcpy(f->phone,ch);strcpy(ch,t->email);strcpy(t->email,f->email);strcpy(f->email,ch);}}}// return head;}void save(struct student *head) //保存为磁盘文件{struct student *p;if((fp=fopen("keshe","w"))==NULL){printf("cannot open this file\n");exit(0);}p=head;while(p!=NULL){fprintf(fp,"%d\n",p->num);fprintf(fp,"%d\n",p->age);fprintf(fp,"%s\n",p->name);fprintf(fp,"%s\n",p->sex);fprintf(fp,"%s\n",p->chushen);fprintf(fp,"%s\n",p->dizhi);fprintf(fp,"%s\n",p->phone);fprintf(fp,"%s\n",p->email);p=p->next;}fclose(fp);}struct student *read() //从磁盘读取文件{struct student *head=NULL;struct student *p=NULL;struct student *t=NULL;int a;// fp=fopen("keshe","r");if((fp=fopen("keshe","r"))==NULL){printf("cannot open this file\n");exit(0);}while(1){t=(struct student *)malloc(len);a=fscanf(fp,"%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&t->num,&t->age,t->name,t->sex,t->chush en,t->dizhi,t->phone,t->email);if(a==0||a==-1)return head;t->next=NULL;if(p==NULL){p=t;head=t;}else{p->next=t;p=p->next;p->next=NULL;}}fclose(fp);}void main(){int code=0;struct student *pt = NULL;while(code!=8){menu();printf("请输入上述序号进行操作:\n");scanf("%d",&code);system("cls");switch(code){case 1:{system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================录入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=creat();save(pt);system("cls");printf("===========================录入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("************录入学生信息成功***********!!\n");printf("按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 2:{system("cls");printf("===========================学生信息表================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();printList(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 3:{int search=0;system("cls");printf("===========================查询学生信息==============================\n");printf("---------------------------------------------------------------------\n");while(search!=3){printf("1、按学号查询\n2、按姓名查询\n3、退出查询\n");scanf("%d",&search);switch(search){case 1:{long search_num;system("cls");printf("请输入学生学号\n");scanf("%d",&search_num);system("cls");printf("===========================查询结果==================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_num(read(),search_num);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};break;case 2:{char search_name[15];system("cls");printf("请输入学生姓名\n");scanf("%s",search_name);system("cls");printf("===========================查询结果==================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_name(read(),search_name);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};}}system("cls");};break;case 4:{long del_num;system("cls");printf("===========================删除学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("请输入要删除学生信息的学号:\n");scanf("%d",&del_num);system("cls");pt=delList(read(),del_num);save(pt);printf("===========================删除结果================================\n");printf("-------------------------------------------------------------------\n");printf("学号为%d的学生信息成功删除\n",del_num);printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 5:{system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================插入学生信息==============================\n");printf("---------------------------------------------------------------------\n");insert(pt);save(pt);system("cls");printf("===========================插入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("****插入学生信息成功***!!\n\n");printf("按回车键返回主菜单\n");getchar();getchar();system("cls");}break;case 6:{long search_num;system("cls");printf("请输入要修改的学生学号:\n");scanf("%d",&search_num);system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================修改学生信息==================================\n");printf("-------------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_num(read(),search_num);printf("\n");printf("请输入修改信息:\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();xiugai(pt,search_num);save(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("****修改学生信息成功***!!\n\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};break;case 7:{system("cls");printf(" 按学号从小到大排序\n\n");printf("===========================学生信息表================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();paixu(pt);printList(pt);save(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 8:read();break;}}}。

学生信息管理系统c语言版源代码

学生信息管理系统c语言版源代码

学生信息管理系统c语言版源代码#include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> #define N 1000typedef struct student {int number;char name[20];int grade;int gaoshu;int yingyu;int jisuanji;int sum;}STUDENT;STUDENT student[N]; int shuliang=0;void menu();void fhzjm(){char biaozhi[20];printf("\n");printf("还需要操作么,如果需要操作请输入:yes,否则请输入:no\n");scanf("%s",biaozhi);if(strcmp(biaozhi,"yes")==0){menu();}else if(strcmp(biaozhi,"no")==0)exit(0);else{printf("请输入正确的字符,谢谢~\n"); fhzjm();}}void DengJi(){int rs;int i,k=1;system("CLS");printf("请输入需要输入几个学生信息:"); scanf("%d",&rs);for(i=shuliang;i<shuliang+rs;i++,k++) {printf("请输入第%d个学生的学号:",k); scanf("%d",&student[i].number);printf("请输入学生的姓名:");scanf("%s",student[i].name);printf("请输入学生3门课的成绩:"); printf("请输入第1门课的成绩:");scanf("%d",&student[i].gaoshu);printf("请输入第2门课的成绩:");scanf("%d",&student[i].yingyu);printf("请输入第3门课的成绩:");scanf("%d",&student[i].jisuanji);}shuliang=shuliang+rs;fhzjm();}void ShanChu(){char shanchuinfo[10];system("CLS");printf("删除全部学生信息请输入\"all\",删除指定学号的学生信息请输入\"one\"\n");scanf("%s",shanchuinfo);if(strcmp(shanchuinfo,"all")==0){int j;printf("你删除的学生信息如下:\n");printf("-----------学号-------------姓名-------------高数--------------英语--------------计算机\t\n");for(j=0;j<shuliang;j++)printf("----%d-------%s-------%d-------%d-------%d\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].jisuanji);shuliang=0;printf("删除成功\n\n");}else if(strcmp(shanchuinfo,"one")==0){struct student *p=NULL;int choice;int i,j,k=0;printf("请输入你要删除的人的学号:");scanf("%d",&choice);for(i=0;i<shuliang;i++){if(choice==student[i].number){k=1;j=i;break;}}if(k){if(shuliang==1){p=&student[0];free(p);shuliang=0;}else{for(i=j;i<shuliang;i++) {student[i]=student[i+1];}shuliang=shuliang-1;}printf("删除成功\n\n");}else{printf("输入数据错误~\n"); }}fhzjm();}void LiuLan(){int i;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息~\n");}else{for(i=0;i<shuliang;i++){printf("第%d个学生的学号为:%d\n",i+1,student[i].number);printf("第%d个学生的姓名为:%s\n",i+1,student[i].name);printf("第%d个学生的第一门课的成绩为:%d\n",i+1,student[i].gaoshu);printf("第%d个学生的第二门课的成绩为:%d\n",i+1,student[i].yingyu);printf("第%d个学生的第三门课的成绩为:%d\n",i+1,student[i].jisuanji);student[i].sum=student[i].gaoshu+student[i].yingyu+student[i].jisuan ji;printf("第%d个学生的总成绩为:%d\n",i+1,student[i].sum);}}fhzjm();}void ChaZhao(){int xx;char choice,yy[20];int i,j,k=0;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息~\n");fhzjm();}printf("三种查找方式:学号,姓名,成绩\n");printf("如果按学号查找请输1,如果按姓名查找请输2,如果按成绩查找请输3\n");printf("请输入您查找的方式:");scanf("%s",&choice);if(choice=='1'){printf("请输入需要查找学生的学号:");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].number){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[i].jis uanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='2'){printf("请输入需要查找学生的姓名:\n");scanf("%s",yy);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(strcmp(yy,student[i].name)==0){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[j].jis uanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='3'){printf("请输入需要查找学生的成绩:\n");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数----英语----计算机----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].grade){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[i].jis uanji);}}if(k==0)printf("输入信息有误:\n");}fhzjm();}void PaiXu(){struct student *p1[N],**p2,*temp;int i,j;system("CLS");p2=p1;for( i=0;i<shuliang;i++){p1[i]=student+i;}for( i=0;i<shuliang;i++){for( j=i+1;j<shuliang;j++){if((*(p2+i))->sum<(*(p2+j))->sum){temp=*(p2+i);*(p2+i)=*(p2+j);*(p2+j)=temp;} }}printf("按照总成绩排序之后的信息为:\n");printf("----学号----姓名----总成绩----\t\n");for( i=0;i<shuliang;i++){student[i].sum=student[i].gaoshu+student[i].yingyu+student[i].jisuan ji;printf("----%d-----%s----%d-----\n",(*(p2+i))->number,(*(p2+i))->name,(*(p2+i))->sum);}fhzjm();}void CunChu(){int i;FILE *rs;if((rs=fopen("student.txt","w"))==NULL){printf("not open");exit(0);}for(i=0;i<shuliang;i++){fwrite(&student[i], sizeof(student[i]), 1, rs); }if(ferror(rs)){fclose(rs);perror("写文件失败~\n");return;}printf("存储文件成功~\n");fclose(rs);fhzjm();}void DaoChu(){struct student t;int i=0;FILE* fp = fopen("student.txt", "r");shuliang=0;if(NULL==fp){perror("读取文件打开失败~\n");return;}memset(student,0x0,sizeof(student));while(1){fread(&t,sizeof(t),1,fp);if(ferror(fp)){fclose(fp);perror("读文件过程失败~\n");return;}if(feof(fp)){break;}student[i]=t;i++;}fclose(fp);shuliang=i; printf("导出文件成功~\n"); fhzjm();}void menu(){int n=0;system("CLS");printf(" 学生信息管理系统\n");printf(" 作者:陈椿\n");printf("-------------------MENU-----------------\n"); printf(" 1.登记学生信息\n");printf(" 2.删除学生信息\n");printf(" 3.浏览所有已经登记的学生\n");printf(" 4.查找\n");printf(" 4.1按学号查找\n");printf(" 4.2按姓名查找\n");printf(" 4.3按成绩查找\n");printf(" 5.根据总成绩排序\n");printf(" 6.存储到文件\n");printf(" 7.从文件导出\n");printf(" 8.退出系统\n");a: printf(" 请选择:");scanf("%d",&n);switch (n){case 1:DengJi();break;case 2:ShanChu();break;case 3:LiuLan();break;case 4:ChaZhao();break;case 5:PaiXu();break;case 6:CunChu();break;case 7:DaoChu();break;case 8:exit(0);break;default:{printf("请输入1-8之间的数字,谢谢~\n"); goto a;}}}main() {menu();}。

学生管理系统c语言源代码

学生管理系统c语言源代码

学生管理系统c语言源代码学生管理系统c语言源代码#include stdio.h#include dos.h#include string.h#include stdlib.h#include malloc.h#define SIZE 8struct student{char name;char num;int score;float ave;struct student *next;}stu[SIZE],temp,s;void shuru(){int i,j,sum,length,flag=1,a;FILE *fp;while(flag==1){printf(“Define a rangeclass number:");scanf("%d",printf("Input the total number of the class(a):"); scanf("%d",length);if(lengtha)flag=0;}for(i=0;ilength;i++){printf("\n请输入学生的信息:");printf("\n输入姓名:");scanf("%s",stu[i].name);printf("\n输入序号.:");scanf("%s",stu[i].num);printf("\n输入成绩:\n");sum=0;for(j=0;jj++){printf("score %d:",j+1);scanf("%d",stu[i].score[j]);sum+=stu[i].score[j];}stu[i].ave=sum/3.0;}学生管理系统c语言源代码fp=fopen("stu1.txt","w");for(i=0;ilength;i++)if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)printf("File write error\n");fclose(fp);fp=fopen("stu1.txt","r");printf("\name\ NO. score1 score2 score3 sum ave\n");for(i=0;ilength;i++){fread(stu[i],sizeof(struct student),1,fp);printf("%3s%5s%7d%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i ].score,stu[i].score,stu[i].score,sum=stu[i].score+stu[i].score+stu[i].score,stu[i].ave);}}void chaxun(){ FILE *fp, *fp1;char n,name;int i,j,k,t,m,flag=1;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");k=i;printf("\nPlease select the menu(1.number ):"); scanf("%d",switch(m){case 1:printf("\nchaxun number:");scanf("%s",n);for(flag=1,i=0;ii++){if(strcmp(n,stu[i].num)==0){j=i;flag=0;break;}}break;case 2:printf("\nchaxun name:");scanf("%s",name);for(flag=1,i=0;ii++){if(strcmp(name,stu[i].name)==0){j=i;flag=0;break;学生管理系统c语言源代码}}}if(!flag){printf("\nYou can find:\n");fp1=fopen("stu2.txt","w");printf(" name NO. score1 score2 score3ave\n");fwrite(stu[j],sizeof(struct student),1,fp1);printf("%-15s%11s%7d%7d%7d%10.2f",stu[j].name,stu[j].num,stu[j].score,stu[j].score,stu[j].score,stu[j].ave);}else printf("\nNot found!");fclose(fp);fclose(fp1);}xiugai(){ int a;printf("\nplease select the menu(1.CHARU 2.__ ):");scanf("%d",switch(a){case 1:Insert(); break;case 2:Delete(); break;}}Insert(){ FILE *fp;int i,j,t,n;printf("\nNO.:");scanf("%s",s.num);printf("name:");scanf("%s",);printf("score1,score2,score3:");scanf("%d,%d,%d",s.score,s.score,s.score);s.ave=(s.score+s.score+s.score)/3.0;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)学生管理系统c语言源代码printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(t=0;stu[t].aves.avett++);printf("\nnow:\n");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fwrite(s,sizeof(struct student),1,fp);printf("\n%-15s%11s%7d%7d%7d%10.2f",,s.num,s.score,s.score, s.score,s.ave);for(i=t;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);}Delete(){ FILE *fp;int i,j,t,n,flag;char number;if((fp=fopen("stu1.txt","rb"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;学生管理系统c语言源代码printf("\nInput number deleted:");scanf("%s",number);for(flag=1,i=0;flagii++){if(strcmp(number,stu[i].num)==0){for(t=i;tt++){strcpy(stu[t].num,stu[t+1].num);strcpy(stu[t].name,stu[t+1].name);for(j=0;jj++)stu[t].score[j]=stu[t+1].score[j];stu[t].ave=stu[t+1].ave;}n=n-1;elseprintf("\n Not found!");printf("\nNow,the content of file:\n");fp=fopen("stu1.txt","wb");for(i=0;ii++)fwrite(stu[i],sizeof(struct student),1,fp);fclose(fp);fp=fopen("stu1.txt","r");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)printf("%-15s%11s%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i].score, stu[i].score,stu[i].score,stu[i].ave);fclose(fp);}paixu(){FILE *fp;int i,j,n;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(i=0;ii++)for(j=i+1;jj++)学生管理系统c语言源代码if(stu[i].avestu[j].ave){temp=stu[i];stu[i]=stu[j];stu[j]=temp;}printf("\nnow:");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);tongji(){ FILE *fp;int i,j,k,labe1,b;int a5=0;int a6=0;int a7=0;int a8=0;int a9=0; int a10=0; float t;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++){printf("\n%-15s%11s",stu[i].name,stu[i].num); for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);k=i;for(i=0;ii++){labe1=0;if(stu[i].ave60){labe1++;t=labe1/(float)k*100;}}printf("\nbujigelv:");printf("%f%",t);printf("\n");for(j=0;jj++){a5=0;a6=0;a7=0;a8=0;a9=0;a10=0;k=i;printf("kemu is %d:\n",j);for(i=0;ii++)学生管理系统c语言源代码{b=stu[i].score[j]/10;if(b6)a5++;elseif(b=6b7)a6++;elseif(b=7b8)a7++;elseif(b=8b9)a8++;if(b=9b10)a9++;elseif(b==10)a10++;}printf(" 不及格is %d\n",a5);printf(" 60--69 is %d\n",a6);printf(" 70--79 is %d\n",a7);printf(" 80--89 is %d\n",a8);printf(" 90--99 is %d\n",a9);printf(" 100 is %d\n",a10);}}main(){int a;printf(" ____\n"); printf(" 欢迎进入学生成绩管理系统\n");printf(" ____\n"); while(1){printf("\n选择菜单:\n");printf("\n");printf(" 1.输入 2.查询 3.排序 4.修改 5.统计 6.退出\n"); scanf("%d",switch(a){case 1: shuru();break;case 2: chaxun(); break;case 3: paixu(); break;case 4: xiugai(); break;学生管理系统c语言源代码case 5: tongji();break; case 6: exit(0); }。

C++大作业:学生信息管理系统(附代码)

C++大作业:学生信息管理系统(附代码)

学生信息管理系统(附代码)题目要求:设计一个类CStudent,类中包含一个学生的基本数据如下:编号,姓名,性别,年龄,数学成绩,计算机成绩,外语成绩。

并假设编号为整数,且从1号往后连续编码;姓名为字符串,性别为字符。

如:1 LiPing m 18 89 98 94请采用binary文件形式,并使用随机读写处理方式,对自定义CStudent类的对象数据进行存储与读写处理(即是说,总按具有连续编码的编号num为“序”来对文件中的各对象数据进行随机读写处理)。

并设计该类的成员函数,而且对输出运算符“<<”进行重载,使该运算符能够完成将一个学生的信息输出到屏幕上。

要求成员函数完成以下功能:(1)从键盘输入一个学生的有关信息,并将它们存入到数据文件中(按编号来确定写出位置)。

(2)按编号对学生信息进行检索并将检索结果显示在屏幕上。

(3)按姓名对学生信息进行检索并将检索结果显示在屏幕上。

(4)计算某编号学生的总成绩与平均成绩。

(5)列出所有总成绩超过n分的性别为s同学的有关信息(n,s由用户从键盘输入)。

Code:1. /****************************************2. *名称: student.cpp *3. *描述: 学生管理程序*4. *功能: 添加,修改,按条件查询学生信息*5. *环境: Fedora Linux 11 & GCC & x86 *6. *备注: davelv第一次Class于2010-01-10 *7. *更新: 新建了可复用的搜索模板searchframe *8. ****************************************/9.10. #include <iostream>11. #include <cstring>12. #include <vector>13. #include <fstream>14. #include <cstdlib>15.16. using namespace std;17. #define CIN_LEN 1024//缓冲区长度18. #define FILENAME "data"//数据文件名19. /////////////////////////////////////20. // 结构和类//21. ///////////////////////////////////22. struct data//学生个人信息23. {24. int id;//学号25. char name[20];//名字26. char major[20];//专业27. char sex;//性别28. double ch,en,ma;//成绩29. int grade;//年级30. };31.32. class CStudent33. {34. protected:35. bool altered;//是否修改36. data info;//学生信息37. public:38. static int nowid ;//新学生自增id39. static void displayhead();//显示表头40. static void displayshorthead();//显示短表头41. CStudent();//构造42. void displayinfo();//显示全部学生信息43. void displayshortinfo();//显示学生短信息44. double getsum();//取总成绩45. double getave();//取得平均分46. double getch();//取语文成绩47. double geten();//取外语成绩48. double getma();//取数学成绩49. int set(bool isnew);//设置学生信息50. int getgrade();//取年级51. int getid();//取学号52. bool isaltered();//取是否修改53. char getsex();//取性别54. char* getname();//取姓名55. char* getmajor();//取专业56. data* getinfo();//取学生全部信息57. //定义友元函数以便重载运算符58. friend ostream& operator<<(ostream&,const CStudent&);59. friend istream& operator>>(istream&,CStudent&);60.61. };62.63. int CStudent::nowid = 1;//初始化类静态成员64.65. CStudent::CStudent()//基类构造66. {67. info.id=CStudent::nowid++;//子增id68. strcpy(,"None");//名字69. info.ch=0;//语文成绩70. info.en=0;//外语成绩71. info.ma=0;//数学成绩72. info.grade=1;//年级73. altered=false;//未被修改74. }75.76. int CStudent::getgrade()77. {78. return info.grade;79. }80.81. double CStudent::getsum()82. {83. return info.ch+info.en+info.ma;84. }85. double CStudent::getave()86. {87. return (info.ch+info.en+info.ma)/3;88. }89. double CStudent::getch()90. {91. return info.ch;92. }93.94. double CStudent::geten()95. {96. return info.en;97. }98.99. double CStudent::getma()100. {101. return info.ma;102. }103.104. int CStudent::getid()105. {106. return info.id;107. }108.109. char CStudent::getsex()110. {111. return info.sex;112. }113.114. char * CStudent::getname()115. {116. return ;117. }118. bool CStudent::isaltered()119. {120. return altered;121. }122. data *CStudent::getinfo()123. {124. return &info;125. }126. void CStudent::displayinfo()127. {128. cout<<*this<<"\t"<<getsum()<<"\t"<<getave()<<endl;//利用重载运算符输出129. }130. void CStudent::displayshortinfo()131. {132. cout << *this<<endl;133. }134. void CStudent::displayhead()135. {136. cout<<"\n\t学号\t姓名\t性别\t专业\t年级\t中文\t英文\t数学\t总分\t平均分\n"; 137. }138. void CStudent::displayshorthead()139. {140. cout<<"\n\t学号\t姓名\t性别\t专业\t年级\t中文\t英文\t数学\n";141. }142. int CStudent::set(bool isalter)143. {144. cout<<"输入学生信息:\n";145. displayshorthead();146. if (isalter)147. displayshortinfo();148. cout<<"\t"<<info.id<<"\t";149. cin.clear();150. cin>> *this;//从标准输入获取学生信息151. altered=true;//已修改152.153. if(cin.fail())154. {155. cout<<"录入失败\n";156. cin.clear();157. cin.ignore(CIN_LEN,'\n');//这两行是用来清空输入缓冲158. return -1;159. }160. else161. {162. cout<<"录入成功\n";163. return 1;164. }165. }166.167. //重载输出符168. ostream &operator<<(ostream& out,const CStudent &right)169. {170. //输出学生的全部信息171. out <<"\t"<<.id<<"\t"<<<<"\t"<<.sex<<"\t" 172. <<.major<<"\t"<<.grade<<"\t"<<.ch<<"\t" 173. <<.en<<"\t"<<.ma;174. return out;175. }176. //重载输入符177. istream& operator>>(istream& in,CStudent& right)178. {179. //输入除ID外的其他信息180. in >>>>.sex>>.major181. >>.grade>>.ch>>.en>>.ma; 182. return in;183. }184.185. /////////////////////////////////186. // 初始化函数//187. ////////////////////////////////188. int initial(vector<CStudent*> &stu)189. {190. fstream file;//输入文件191. CStudent *p;192.193. file.open(FILENAME, fstream::in|fstream::binary);//二进制输入打开194.195. if (!file)//文件是否打开成功196. return -1;197. while( file.peek()!=EOF )//是否到文件末尾198. {199. p=new CStudent();//新建一个学生对象200. file.read((char*) p->getinfo(),sizeof(data));//读入学生对象201. if(file.fail())//检查读入是否失败202. return -2;203. stu.push_back(p);//对象加入vector204. }205. if(!stu.empty())//如果从文件读入了对象206. CStudent::nowid = stu.back()->getid()+1;//则自增id设置为最后一个学生id+1 207. file.close();//关闭208. return stu.size();//返回对象个数209. }210. ////////////////////////////////211. // 信息增加函数//212. ///////////////////////////////213. void insert(vector<CStudent*> &stu)214. {215. char c='y';//输入控制字符216.217. int flag = 1;//标志位,1表示新增成功218.219. CStudent *p=new CStudent();220.221. while(c != 'n')//是否继续新增222. {223. flag = p->set(false);//设置学生信息224. if( flag == 1 )//如果设置成功225. {226. stu.push_back(p);//对象加入vector227. p = new CStudent();//新建下一个对象228. }229. cout << "是否继续添加学生(any/n)?";230. cin.clear();231. cin.ignore(CIN_LEN,'\n');232. cin.get(c);233. }234. //删除最后一个新建的对象,因为没有使用它235. delete p;236. CStudent::nowid--;237. }238.239. ///////////////////////////////240. // 查询全部信息函数//241. /////////////////////////////242. int comparebynone(const void *a, const void *b )243. {244. return 0;245. }246. ////////////////////////////////247. // 按学号比较函数//248. //////////////////////////////249. int comparebyid(const void *a, const void *b )250. {251. return *(const int *)a - ((CStudent *)(b))->getid();252. }253. ///////////////////////////////254. // 按姓名比较函数//255. //////////////////////////////256. int comparebyname(const void *a, const void *b )257. {258. return strcmp((const char *)a, (const char *)(((CStudent *)b)->getname())); 259. }260. ////////////////////////////////261. // 按年级比较函数//262. //////////////////////////////263. int comparebygrade(const void *a, const void *b)264. {265. return (*(const int *)a - ((CStudent *)b)->getgrade());266. }267. /////////////////////////////////////268. // 按总分和性别比较函数//269. ///////////////////////////////////270. int comparebymarkandsex(const void *a, const void *b)271. {272. double mark;273. char sex;274. sscanf((const char*)a,"%lf%c",&mark,&sex);275. return !(276. ( ((CStudent*)b)->getsum() >= mark )277. && ( (sex =='n') || (sex == ((CStudent*)b)->getsex()) )278. );279.280.281. }282. ///////////////////////////////283. // 搜索模板//284. /////////////////////////////285. template <typename T>286. void searchframe(const char *info, T &condition ,vector<CStudent *> &stu, int (*compare)(const void *a, const void *b) ,bool isalter)287. {288. char c='y';289. int flag;290. while(c != 'n')291. {292. cin.clear();293.294. if(info != NULL)295. {296. cout<< "输入"<<info<<":";297. //cin.ignore(CIN_LEN,'\n');298. cin>>condition;299. }300.301. if(cin.fail())302. {303. cout << "输入错误\n";304. }305. else306. {307. //遍历vector查找308. for(vector<CStudent*>::size_type ix =flag=0; ix!=stu.size(); ++ix)309. { //判断是name是否相等310. if(compare(&condition,stu[ix]) == 0)311. {312. if( isalter )313. stu[ix]->set(isalter);314. else315. {316. if(flag == 0)317. CStudent::displayhead();318. stu[ix]->displayinfo();319. }320. flag = 1;321. }322. }323. if (flag == 0)//没有查到324. {325. cout<<"没有";326. if(info == NULL)327. cout<<"符合条件";328. else329. cout<<info<<"为"<<condition;330. cout<<"的学生\n";331. }332. }333. cout << "是否继续(any/n)?";334. cin.clear();335. cin.ignore(CIN_LEN,'\n');336. cin.get(c);337. }338. }339.340. ////////////////////////////////341. // 信息检索函数//342. //////////////////////////////343. void fetch(vector<CStudent*> &stu)344. {345. int choose,id,grade;346. char name[20],markandsex[20];347.348. while (true)349. {350. cout << "\n\t1.显示全部学生信息\n"351. "\t2.按学号查学生信息\n"352. "\t3.按姓名查学生信息\n"353. "\t4.按年级查学生信息\n"354. "\t5.按成绩和性别查询\n"355. "\t6.返回上级菜单\n\n";356. lchoose:357. cout<<"输入您的选择:";358. choose=0;359. cin>>choose;360. switch(choose)361. {362. case 1 :searchframe(NULL,choose,stu,comparebynone,false); break; 363. case 2 :searchframe("学号",id,stu,comparebyid,false); break;364. case 3 :searchframe("姓名",name,stu,comparebyname,false); break;365. case 4 :searchframe("年级",grade,stu,comparebygrade,false); break;366. case 5 :searchframe("分数和性别",markandsex,stu,comparebymarkandsex,false); break;367. case 6 :return ;368. default: cout<<"输入有误\n";cin.clear();cin.ignore(CIN_LEN,'\n');goto lchoose;369. }370. }371. }372. ////////////////////////////////373. // 信息保存函数//374. //////////////////////////////375. int save(vector<CStudent*> &stu)376. {377. fstream file;378.379. file.open(FILENAME, fstream::out|fstream::binary);//二进制写打开文件380. if (!file)//判断打开是否成功381. return -1;382. //遍历全部对象383. for(vector<CStudent*>::size_type ix =0; ix!=stu.size(); ++ix)384. { //判断当前对象是否已修改385. if(stu[ix]->isaltered())386. { //修改了则写入文件387. file.seekp(ix*sizeof(data));388. file.write((char*) stu[ix]->getinfo(),sizeof(data));389. //写入是否成功390. if(file.fail())391. return -2;392. }393.394. }395. file.close();396. return 0;397. }398.399. ///////////////////////////////400. // 主函数//401. //////////////////////////////402.403. int main()404. {405. vector<CStudent *> stu ;406.407. system("clear");//清屏408. //读入数据文件409. if(initial(stu)<0)410. {411. cout<<"初始化失败,请检查数据文件\""<<FILENAME<<"\"是否完好\n"; 412. return -1;413. }414.415. int choose;416. //主菜单循环417. while(true)418. {419. cout << "\n *----------学生信息管理系统----------*\n\n" 420. " 1.录入信息\n"421. " 2.修改信息\n"422. " 3.检索学生\n"423. " 4.保存数据\n"424. " 5.保存退出\n"425. " 6.不保存退出\n\n"426. " *---------modify by davelv-----------*\n";427. lchoose:428. cout<<"输入您的选择:";429. choose=0;430. cin>>choose;431. switch(choose)432. {433. case 1 :insert(stu);break;434. case 2 :searchframe("学号",choose,stu,comparebyid,true);break;435. case 3 :fetch(stu);break;436. case 4 :if(save(stu) <0 )437. {438. cout<<"保存失败,请检查数据文件\""<<FILENAME<<"\"是否完好\n";439. };break;440. case 5 :if(save(stu) <0 )441. {442. cout<<"保存失败,请检查数据文件\""<<FILENAME<<"\"是否完好\n";443. }return 0;444. case 6 :return 0;445. default:cout<<"输入有误\n";cin.clear();cin.ignore(CIN_LEN,'\n');goto lchoose;446. }447. } 448. return 0; 449. }。

c语言大作业学生管理系统

c语言大作业学生管理系统

c语言大作业学生管理系统随着信息化的快速发展,计算机技术已经深入到各个领域。

在教育领域中,学生管理系统是学校管理学生信息的重要工具。

本次大作业将以“c语言大作业学生管理系统”为题,介绍如何使用c语言开发一个简单的学生管理系统。

一、需求分析学生管理系统需要实现以下功能:1、添加学生信息2、查询学生信息3、修改学生信息4、删除学生信息5、显示所有学生信息二、设计1、定义数据结构为了存储学生信息,我们可以定义一个结构体,包含学生的姓名、学号、性别、年龄等信息。

cinclude <stdio.h>include <stdlib.h>include <string.h>typedef struct {char name;char id;char gender;int age;Student;2、定义函数为了实现学生管理系统的各个功能,我们可以定义以下函数:1、add_student():添加学生信息2、query_student():查询学生信息3、modify_student():修改学生信息4、delete_student():删除学生信息5、display_students():显示所有学生信息三、实现下面是一个简单的实现示例:cinclude <stdio.h>include <stdlib.h>include <string.h>typedef struct {char name;char id;char gender;int age;Student;void add_student(Student *students, int *num_students) { Student student;printf("Enter name: ");scanf("%s", );printf("Enter ID: ");scanf("%s", student.id);printf("Enter gender: ");scanf("%s", student.gender);printf("Enter age: ");scanf("%d", &student.age);students[*num_students] = student;(*num_students)++;printf("Student added successfully.C语言学生信息管理系统实验报告C语言学生信息管理系统实验报告一、实验目的本实验旨在通过使用C语言编写学生信息管理系统,提升我们的编程技能和系统设计能力。

C语言课程设计——学生管理系统源代码

C语言课程设计——学生管理系统源代码

C语言课程设计——学生管理系统源代码#include〈stdio。

h>#include〈stdlib。

h〉#include<string。

h〉#include〈conio.h>#define MY1 printf(”学号\t姓名\t性别\t年龄\t生日”)#define MY2 printf(”\n%d %6s %4s\t%2d %8d%2d%2d \n",s[i].num,s[i].name,s[i]。

sex,s[i]。

age,s[i]。

a。

year,s[i].a。

month,s[i].a.day)#define MY3 printf(”家庭住址联系方式高数英语大物总成绩")#define MY4 printf(”\n%4s %4s %2d %2d %2d %2d\n”,s[i]。

address,s[i]。

tel,s[i].c。

gao,s[i]。

c.ying,s[i].c.wu,s[i].c.total)#define MAX 30int i;int sum;/*时间结构体类型*/struct date{int year;int month;int day;}a;/*学生成绩结构体类型*/struct score{int gao;int ying;int wu;int total;}c;/*学生信息结构体类型*/struct s_message{int num;char name[20];char sex[5];int age;struct date a;char address[50];char tel [11];struct score c;}s[MAX];/*保存学生信息模块*/int i;FILE*fp;if((fp=fopen(”D:\\s。

txt",”wb”))==NULL){printf(”reading file is wrong!\n”);return;}for (i=0;i<sum;i++){if(fwrite(&s[i],sizeof(struct s_message),1,fp)!=1)printf(”writing file is wrong!\n”);}fclose(fp);}/*读取学生信息模块*/int read_message(){FILE *fp;int i=0;if((fp=fopen("D:\\s。

c大作业学生信息管理系统源代码

c大作业学生信息管理系统源代码

学生信息管理系统源代码:#include<>#include<>#include<>#include<>#include<>#include<>structstudent{charnum[30];intmaths;charname[30];intchinese;charclas[30];intenglish;inttotal;floataverage;student*next;};<<endl;abort();}(t,80);while(instuf>>num0>>name0>>clas0>>chinese0>>maths0>>english0){s=newstudent;strcpy(s->num,num0);strcpy(s->name,name0);strcpy(s->clas,clas0);s->chinese=chinese0;s->maths=maths0;s->english=english0;s->total=s->chinese+s->maths+s->english;s->average=float(s->total)/3;if(head==NULL)head=s;elsep->next=s;p=s;}p->next=NULL;();}<<endl;abort();}outstuf<<"学号姓名班级语文数学英语总分均分序号"<<endl;while(head){outstuf<<head->num<<""<<head->name<<'\t'<<head->clas<<'\t'<<""<<head->chinese<<'\t'<<head->maths<<'\t'<<head->english<<'\t'<<head->total<<'\t'<<setprecision(3)<<head->average<<'\t'<<""<<n<<endl;n=n+1;head=head->next;}();}voidmain(){student*head=NULL;intn;chars[30];cout<<"********************************************************************************"; cout<<"*★欢迎使用学生成绩管理系统★*";cout<<"*管理员:XXX*";cout<<"*请选择您想使用的功能:*";cout<<"*功能名请输入功能名请输入*";cout<<"*◆导入学生成绩文件1◆按学号小到大排序7*";cout<<"*◆插入学生成绩信息2◆按姓名首字母排序8*";cout<<"*◆删除学生成绩信息3◆按班级的类别排序9*";cout<<"*◆修改学生成绩信息4◆导出学生成绩文件10*";cout<<"*◆查询学生成绩信息5◆其它功能......*";cout<<"*◆按成绩高到低排序6◆退出管理系统0*";cout<<"********************************************************************************"; cout<<"您的输入是:";cin>>n;createlist(head);while(n>0){switch(n){case1:cout<<"导入的需管理的学生成绩信息表:"<<endl;showlist(head);break;case2:charu(head);cout<<"插入后的学生成绩信息表:"<<endl;showlist(head);break;case3:shanchu(head);cout<<"删除后的学生成绩信息表:"<<endl;showlist(head);break;case4:change(head);cout<<"修改后的学生成绩信息表:"<<endl;showlist(head);break;case5:cout<<"请选择查询学生成绩的方式:"<<endl;cout<<"方式请输入方式请输入"<<endl;cout<<"●查询个人成绩1●查询数学成绩4"<<endl;cout<<"●查询班级成绩2●查询英语成绩5"<<endl;cout<<"●查询语文成绩3●查询总分成绩6"<<endl;cout<<"您的输入是:";cin>>n;switch(n){case1:geren(head);break;case2:zongfen(head);chabanji(head);break;case3:yuwen(head);chayuwen(head);break;case4:shuxue(head);chashuxue(head);break;case5:yingyu(head);chayingyu(head);break;case6:zongfen(head);chazongfen(head);break;}break;case6:cout<<"请选择需排序的成绩的类型:"<<endl;cout<<"类型请输入类型请输入"<<endl;cout<<"●按语文成绩排序1●按英语成绩排序3"<<endl; cout<<"●按数学成绩排序2●按总分成绩排序4"<<endl; cout<<"您的输入是:";cin>>n;switch(n){case1:yuwen(head);cout<<"按【语文】成绩排序后的学生成绩信息表:"<<endl; showlist(head);break;case2:shuxue(head);cout<<"按【数学】成绩排序后的学生成绩信息表:"<<endl; showlist(head);break;case3:yingyu(head);cout<<"按【英语】成绩排序后的学生成绩信息表:"<<endl; showlist(head);break;case4:zongfen(head);cout<<"按【总分】成绩排序后的学生成绩信息表:"<<endl;showlist(head);break;}break;case7:xuehao(head);cout<<"按【学号】从小到大排序后的学生成绩信息表:"<<endl;showlist(head);break;case8:xingming(head);cout<<"按【姓名】首字母排序后的学生成绩信息表:"<<endl;showlist(head);break;case9:banji(head);cout<<"按【班级】的类别排序后的学生成绩信息表:"<<endl;showlist(head);break;case10:cout<<"请选择需导出的学生成绩数据文件的内容:"<<endl;cout<<"内容请输入内容请输入";cout<<"●按总分成绩排序的成绩表1●按姓名首字母排序的成绩表3"; cout<<"●按学号大小排序的成绩表2●按班级分类别排序的成绩表4"; cout<<"您的输入是:";cin>>n;switch(n){case1:zongfen(head);cout<<"按【总分】成绩排序的成绩表已导出"<<endl;cout<<"在生成的文件中"<<endl;cout<<"请注意查看!"<<endl;strcpy(s,"");show(head,s);break;case2:xuehao(head);cout<<"按【学号】大小排序的成绩表已导出"<<endl;cout<<"在生成的文件中"<<endl;cout<<"请注意查看!"<<endl;strcpy(s,"");show(head,s);break;case3:xingming(head);cout<<"按【姓名】首字母排序的成绩表已导出"<<endl;cout<<"在生成的文件中"<<endl;cout<<"请注意查看!"<<endl;strcpy(s,"");show(head,s);break;case4:banji(head);cout<<"按【班级】分类排序的成绩表已导出"<<endl;cout<<"在生成的文件中"<<endl;cout<<"请注意查看!"<<endl;strcpy(s,"");show(head,s);break;}break;}cout<<"继续操作请按回车键!"<<endl;cgets(s);cout<<endl<<endl<<endl;cout<<"********************************************************************************"; cout<<"*★欢迎使用学生成绩管理系统★*";cout<<"*管理员:XXX*";cout<<"*请选择您想使用的功能:*";cout<<"*功能名请输入功能名请输入*";cout<<"*◆导入学生成绩文件1◆按学号小到大排序7*";cout<<"*◆插入学生成绩信息2◆按姓名首字母排序8*";cout<<"*◆删除学生成绩信息3◆按班级的类别排序9*";cout<<"*◆修改学生成绩信息4◆导出学生成绩文件10*";cout<<"*◆查询学生成绩信息5◆其它功能......*";cout<<"*◆按成绩高到低排序6◆退出管理系统0*";cout<<"********************************************************************************"; cout<<"您的输入是:";cin>>n;}cout<<endl<<"您所使用的功能已完成,谢谢使用!"<<endl;cout<<"欢迎再次使用!"<<endl<<endl;}。

学生信息管理系统c语言代码

学生信息管理系统c语言代码

学生信息管理系统c语言代码以下是一个简单的学生信息管理系统的 C 语言代码示例,包含了学生信息的添加、查询、修改和删除功能。

由于代码超过了 400 字,我将提供一个简化的版本,你可以根据需要进行扩展和改进。

```c#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX_STUDENTS 100// 学生结构体struct Student {char id[10];char name[50];int age;};// 学生信息列表struct Student students[MAX_STUDENTS];// 学生数量int studentCount = 0;// 添加学生信息void addStudent() {if (studentCount >= MAX_STUDENTS) {printf("学生数量已满,无法添加更多学生。

\n");return;}printf("请输入学生 ID: ");scanf("%s", students[studentCount].id);printf("请输入学生姓名: ");scanf("%s", students[studentCount].name);printf("请输入学生年龄: ");scanf("%d", &students[studentCount].age);studentCount++;printf("学生信息添加成功。

\n");}// 查询学生信息void queryStudent() {if (studentCount == 0) {printf("没有学生信息可供查询。

C语言学生管理系统代码

C语言学生管理系统代码
float average; //平均分
struct scores *snext;
}stscores;
//宏定义学生个人信息
#define stmes (stmessage *)malloc(sizeof(stmessage)) //为学生个人信息结构体开辟动态内存空间
fflush(stdin);
s--;
}
switch(a)
{
case '1': mainmessage(); continue;//学生基本信息
case '2': mainresult();continue;//学生的成绩信息
case '3': exit(1);//退出系统
void xiugairesult();//修改学生成绩信息
void delatemessag1();//删除学生个人基本信息
void delatemessag2();//删除班级学生基本信息
void delatemessag3();//删除系基本信息
void delatemessag4();//删除全校基本信息
void ziresult4();//学生成绩信息修改菜单
void addmessage();//添加学生基本信息
void judgefile();//判断文件是否存在
void addresult();//添加学生成绩信息
void searchresult();//查询学生成绩信息
void readresult();//加载学生成绩信息到程序
//全局变量
stmessage *head=NULL;
stscores *shead=NULL;

学生管理系统源代码

学生管理系统源代码

#include<iostream>#include<stdlib.h>#include<string.h>#include<malloc.h>#define INIT_SIZE 10#define INCRE_SIZE 10#define SUBJECT_NUM 3#define LEN 3void show_Start();void show_Table();void addRecord();void Info_delete();void deleteRecord();void delete_Num(int);void delete_Name(char tarName[]);void Info_modify();void modifyRecord();void modify_Num(int);void modify_Name(char[]);void Info_query();void queryRecord();void query_Num(int);void query_Name(char[]);void display();void quit();void menu_CMD();char *subject[SUBJECT_NUM] =struct STUDENT{int num;char name[20];char sex;float score[SUBJECT_NUM];};//struct STUDENT stu[LEN + 1];//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);int static stuNum = 0;//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);;int main(){//record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);/*record[1].num = 1001;strcpy(record[1].name,"Jason");record[1].sex = 'M';record[1].score[0] = 85.0;record[1].score[1] = 90.0;record[1].score[2] = 95.0;record[2].num = 1002;strcpy(record[2].name,"Jerry");record[2].sex = 'M';record[2].score[0] = 85.0;record[2].score[1] = 90.0;record[2].score[2] = 95.0;record[3].num = 1003;strcpy(record[3].name,"Jessie");record[3].sex = 'F';record[3].score[0] = 85.0;record[3].score[1] = 90.0;record[3].score[2] = 95.0;*//*Info_modify();int key;cout<cin>>key;if(key == 1){int targetNum;coutcin>>targetNum;modify_Num(targetNum);cout<<endl;display();}if(key == 2){char targetName[20];cout<cin>>targetName;modify_Name(targetName);cout<<endl;display();}if(key == 3){exit(0);}*/show_Start();menu_CMD();return 0;}void show_Start(){//cout<<endl;cout<<" **************************************** "<<endl;cout<<" "<<endl;cout<<" "<<endl;cout<<" "<<endl;cout<<" "<<endl;cout<<" Made by Jason "<<endl; cout<<" **************************************** "<<endl;}//.void show_Table(){cout<<" <<"\t"<<" "<<"\t"<<"cout<<"\t"<<subject[0]<<"\t"<<subject[1]<<"\t"<<subject[2];cout<<endl;}void menu_CMD(){int key;while(1){cout<<"1. <<endl; cout<<"2. <<endl; cout<<"3. <<endl; cout<<"4. <<endl; cout<<"5. <<endl; cout<<"6. <<endl; cout<<"cin>>key;while(1){if((key < 1)||(key > 6)){int key;cout<< "<<endl; cout<< (1 - 5) : "; cin>>key;}else{break;}}switch(key){case 1:addRecord();break;case 2:deleteRecord();break;case 3:modifyRecord();break;case 4:queryRecord();break;case 5:display();break;case 6:quit();break;}}}/////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////void addRecord(){if(stuNum == 0){cout<< <<endl;stuNum++;}else{cout<<" <<endl;stuNum++;}//if(stuNum > INIT_SIZE){cout<< "<<endl;record = (STUDENT*)realloc(record,(INIT_SIZE + INCRE_SIZE)*sizeof(STUDENT));cout<<" !"<<endl;}cout<<" <<endl;cout<<" (Y/N) : ";char choi;cin>>choi;if((choi == 'Y')||(choi == 'y')){cout<<" : ";cin>>record[stuNum].num;cout<<" : ";cin>>record[stuNum].name;cout<<"(M , F) : ";cin>>record[stuNum].sex;int i;for(i = 0;i < SUBJECT_NUM;i++){cout<<" "<<subject[i]<< : ";cin>>record[stuNum].score[i];}}if((choi == 'N')||(choi == 'n')){cout<<" <<endl;cout<<endl;}cout<< <<stuNum<<" !"<<endl; cout<<endl;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \//deleteRecordvoid Info_delete(){cout<<" : "<<endl;cout<<"1. "<<endl;cout<<"2. <<endl;cout<<"3. "<<endl; }//void deleteRecord(){int key;cout<<endl;Info_delete();cout<<" : "; cin>>key;if(key == 1){int targetNum;cout<<" : ";cin>>targetNum;//delete_Num(targetNum);cout<<endl;}if(key == 2){char targetName[20];cout<<" : "; cin>>targetName;delete_Name(targetName); cout<<endl;}if(key == 3){while(1){menu_CMD();}}}//void delete_Num(int tarNum){int i;for(i = 1;i <= stuNum;i++){if(record[i].num == tarNum){////1.//2.if(i = stuNum){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"<<record[i].score[0]<<record[i].score[1]<<"\t"<<record[i].score[2];cout<<endl;cout<<endl<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum - 1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}stuNum--;cout<<" <<stuNum<<";cout<<endl;*/}//2.if(i != stuNum){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];for(int j = i+1;j <= stuNum;j++){record[j-1] = record[j];}//cout<<endl;cout<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum-1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}/*stuNum--;cout<<" "<<stuNum<<"cout<<endl;*/}stuNum--;cout<<" "<<stuNum<<cout<<endl;}}}/*//void delete_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){if(strcmp(record[i].name,tarName) == 0){////1.//2.//if(i = stuNum){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"<<record[i].score[0]<<record[i].score[1]<<"\t"<<record[i].score[2];cout<<endl;cout<<endl<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum - 1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}}/if(i != stuNum){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];//for(int j = i+1;j <= stuNum;j++){record[j-1] = record[j];}cout<<endl;//cout<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum-1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}cout<<endl;void delete_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){////1.//2.// if(strcmp(record[i].name,tarName) == 0){if(i == stuNum){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];cout<<endl;cout<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum-1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}/*stuNum--;cout<<" "<<stuNum<<" ";cout<<endl;}/if(i != stuNum){cout<<" "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t";cout<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];cout<<endl;for(int j = i+1;j <= stuNum;j++){record[j-1] = record[j];}//. cout<<endl;cout<<" : "<<endl;show_Table();for(int i = 1;i <= stuNum-1;i++){cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(int j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}/*stuNum--;cout<<" "<<stuNum<<cout<<endl;*/}stuNum--;cout<<" <<stuNum<< ";cout<<endl;}}}/***************************************************************************** ******************************************************************************/void Info_modify(){cout<<"\ : "<<endl;cout<<"1. "<<endl;cout<<"2. "<<endl;cout<<"3. "<<endl;}void modifyRecord(){int key;cout<<endl;Info_modify();cout<<" : ";cin>>key;//if(key == 1){int targetNum;cout<< : ";cin>>targetNum;modify_Num(targetNum);cout<<endl;//display();//if(key == 2){char targetName[20];cout<< : ";cin>>targetName;modify_Name(targetName); cout<<endl;//display();}if(key == 3){while(1){menu_CMD();}}}//void modify_Num(int tarNum) {int i;for(i = 1;i <= stuNum;i++) {if(record[i].num == tarNum) {cout<<endl<<" "<<endl;cout<<" : ";cin>>record[i].num;cout<<" : ";cin>>record[i].name;cout<<";cin>>record[i].sex;cout<<" "<<subject[0]<<" ";cin>>record[i].score[0];cout<<" "<<subject[1]<<" : ";cin>>record[i].score[1];cout<<" "<<subject[2]<< ";cin>>record[i].score[2];}}}void modify_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){if(strcmp(record[i].name,tarName) == 0) {cout<<endl<<" : "<<endl;cout<<" : ";cin>>record[i].num;cout<<" : ";cin>>record[i].name;cout<<" : ";cin>>record[i].sex;cout<<" "<<subject[0]<<" : ";cin>>record[i].score[0];cout<<" "<<subject[1]<<" : ";cin>>record[i].score[1];cout<<" "<<subject[2]<<" : ";cin>>record[i].score[2];}}}void Info_query(){cout<<" : "<<endl; cout<<"1. "<<endl; cout<<"2. "<<endl; cout<<"3. "<<endl; }//queryRecordvoid queryRecord(){int key;cout<<endl;Info_query();cout<<" ";cin>>key;if(key == 1){int targetNum;cout<<" : ";cin>>targetNum;query_Num(targetNum);cout<<endl;}if(key == 2){char targetName[20];cout<<" : ";cin>>targetName;query_Name(targetName);cout<<endl;}// .if(key == 3){while(1){menu_CMD();}void query_Num(int tarNum){int i;for(i = 1;i <= stuNum;i++){if(record[i].num == tarNum){// cout<<" : "<<endl;//show_Table();// cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;cout<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[ 2];cout<<endl;}}}//void query_Name(char tarName[]){int i;for(i = 1;i <= stuNum;i++){if(strcmp(record[i].name,tarName) == 0){cout<<" : "<<endl;show_Table();cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;cout<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[ 2];cout<<endl;}}}//void display(){show_Table();int i,j;for(i = 1;i <= stuNum;i++){//cout<<"学号"<<"\t"<<"姓名"<<"\t"<<"性别";cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;for(j = 0;j < SUBJECT_NUM;j++){cout<<"\t"<<record[i].score[j];}cout<<endl;}cout<<endl;}//void quit(){char choi;cout<<" "<<endl;cout<<" (Y/N) : ";cin>>choi;if((choi == 'Y')||(choi == 'y')){cout<< "<<endl;exit(0);}/ else{cout<<endl; menu_CMD();。

C语言学生信息管理系统(附源码)

C语言学生信息管理系统(附源码)
getch();
fclose(fp);
return;
}
printf("姓名:");
scanf("%s",stu[m].name);
printf("语文成绩:");
scanf("%f",&stu[m].chinese);
printf("数学成绩:");
scanf("%f",&stu[m].math);
char ch[2];
if((fp=fopen("stuData.txt","rb"))==NULL)
{
printf("打开文件失败\n");
return;
}
while(!feof(fp))
if(fread(&stu[m],LEN,1,fp)==1)
m++;
fclose(fp);
if(m==0)
{
printf("文件无记录!\n");
default:printf("输入有误,请重新输入:");break;
}
getch();
menu();
scanf("%d",&n);
}
return 0;
}
/*******自定义函数实现菜单功能******/
void menu()
{
system("cls");
printf("\t\t|-------------学生信息系统----------|\n");
printf("\t\t| |\n");

【精】【C语言】班级学生信息管理系统源代码

【精】【C语言】班级学生信息管理系统源代码

#include<stdio.h>#include<windows.h>#include<conio.h>int add();int amend();int remove();int show_student();int show_class();struct info //定义结构体info,用于存储学生信息{char name[20]; //姓名char sex[20]; //性别char idcard[20]; //身份证号码char stuid[10]; //学号char academe[20]; //学院char specialty[20]; //专业char classid[20]; //班级char home[20]; //生源地}stu[100];int j=0;int main(void) //主函数{/*登陆界面设计*/char gongnengxuanzhe;int flag=1;system("cls");printf("\n");printf("\t\t\t\t 欢迎\n");printf("\n\n\t尊敬的用户,非常感谢您使用本系统,您的完美体验将是我们前进的方向!\n\n\n");printf("\t系统功能简介:\n\n\n");printf("\t\t①:通过键盘输入某位学生的学生证信息。

\n\n");printf("\t\t②:给定学号,显示某位学生的学生证信息。

\n\n");printf("\t\t③:给定某个班级的班号,显示该班所有学生的学生证信息。

\n\n");printf("\t\t④:给定某位学生的学号,修改该学生的学生证信息。

\n\n");printf("\t\t⑤:给定某位学生的学号,删除该学生的学生证信息。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

c大作业学生信息管理系统源代码
学生信息管理系统源代码:
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<iomanip.h>
#include<fstream.h>
struct student
{
char num[30]; int maths;
char name[30]; int chinese;
char clas[30]; int english;
int total; float average;
student *next;
};
//◆1(1)
void createlist(student * & head) //学生成绩文件导入功能(用链表储存)
{
char t[80],num0[30],name0[30],clas0[30];
int chinese0,maths0,english0;
student *s,*p;
ifstream instuf("student-score.txt",ios::in);
if (!instuf) {cerr<<"file could not be open."<<endl; abort();}
instuf.getline(t,80);
while
(instuf>>num0>>name0>>clas0>>chinese0>>maths0>>english0)
{
s=new student;
strcpy(s->num,num0);strcpy(s->name,name0);strcpy(s-
>clas,clas0);
s->chinese=chinese0;s->maths=maths0;s->english=english0; s->total=s->chinese+s->maths+s->english; s->average=float(s->total)/3;
if (head==NULL) head=s;
else p->next=s;
p=s;
}
p->next=NULL;
instuf.close();
}
//◆1(2)
void showlist(student *head) //学生成绩信息显示功能(遍历链表)
{
int n=1;
cout<<"学号姓名班级语文数学英语总分均分序号 ";
while (head)
{
cout<<head->num<<" "<<head->name<<'\t'<<head->clas<<'\t'<<" "<<head->chinese<<'\t'
<<head->maths<<'\t'<<head->english<<'\t'<<head-
>total<<'\t'<<setprecision(3)<<head->average<<'\t'<<" "<<n<<endl;
n=n+1;
head=head->next;
}
}
//◆2
void charu(student *head) //学生成绩信息插入功能(链表尾部插入学生成绩信息)
{
student *s,*p,*q;
int n,i;
cout<<"请输入需要【插入】的学生成绩信息的数量: ";
cin>>n;
cout<<"请输入需插入的学生成绩信息(每人一行):"<<endl;
cout<<"学号姓名班级语文数学英语"<<endl;
p=head;
while (p)
{
q=p;
p=p->next;
}
for (i=1;i<=n;i++)
{
s=new student;
cin>>s->num>>s->name>>s->clas>>s->chinese>>s->maths>>s->english;
s->total=s->chinese+s->maths+s->english; s-。

相关文档
最新文档