C语言编写的完整学生管理系统

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
printf("\n sex(boy=1,girl=2):");
scanf("%d",&students[i].sex);
printf("\n birth(yyyy-mm-dd):");
scanf("%d-%d-%d",&students[i].birthday.year,&students[i].birthday.month,\
/*printf(" 3.by sex\n\n");*/
printf(" 0.menu\n\n");
printf(" please choose(0~2)");
scanf("%d",&choice);
switch(choice)
{ case 1: sort_by_num();break;
case 2: sort_by_classes();break;
scanf("%d",&students[i].num);
if(students[i].num==0) break;
printf("\n name:");
scanf("%s",students[i].name);
printf("\n class:");
scanf("%d",&students[i].classes);
{ if(students[i].num!=0)
{
j++;
if(j%PAGE!=0)
{
PRINT3;
PRINT1;
}
else
{
PRINT3;
PRINT1;
if(students[i+1].num!=0)
{
printf("any key to go on!");
clrscr();
printf("\n\n --students data-- page%d\n\n",++page);
printf(" 1.by name\n\n");
printf(" 2.by number\n\n");
printf(" 0.menu\n\n");
printf(" please choose(0~2):");
scanf("%d",&choice);
switch(choice)
{case 2: find_by_num();break;
{ if (students[k].sex>students[j].sex)
k=j;
}
t=students[i];
students[i]=students[k];
students[k]=t;
}
printf("\n\n\n");
PRINT1;
PRINT2;
for(i=0;i<sum;i++)
PRINT3;
#include"stdio.h"
#include"stdlib.h"/*标准库函数*/
#include"string.h"/*字符串操作函数*/
#define MAX 5
#define PAGE 2
#define PRINT1 printf("--------------------------------------------------------------\n");
PRINT2;
for(i=0;i<sum;i++)
PRINT3;
getchar();
return(0);
}
/*按学生性别排序*/
/* void sort_by_sex()
{
int i,j,k;
clrscr();
for(i=0;i<sum-1;i++)
{
k=i;
for(j=i+1;j<sum;j++)
int input_message()
{
int i=sum,s=MAX,k=0;
do
{
clrscr();
printf("input data(maxis %d)\n",s);
PRINT1;
printf(" \n number%dstudents",i+1);
printf("\n number:");
{
printf("wrong!\n");
return 0;
}
for(i=0;i<sum;i++)
if(fwrite(&students[i],sizeof(struct students_type),1,fp)!=1)
printf("wrong!\n");
fclose(fp);
return i;
}
/*录入信息*/
/*case 3: sort_by_sex();break;*/
case 0: break;
}
}
while(choice!=0);
}
/*查询方式*/
/*按姓名查询*/
int find_by_name()
{
int i,j=0;
char inquire_name[20];
clrscr();
printf("\n input the name:");
return (0);
}
/*else
{ printf("\n\n\n\n\n **************students data system**************\n\n");
printf("\n\n **********data saved.any key to menu**********\n\n");
printf(" -------------------\n");
do
{
printf("\n add number:");
students[k]=t;
}
printf("\n\n\n");
PRINT1;
PRINT2;
for(i=0;i<sum;i++)
PRINT3;
getchar();
return (0);
}
/*按学生班级排序*/
sort_by_classes()
{
int i,j,k;
clrscr();
for(i=0;i<sum-1;i++)
case 1: find_by_name();break;
case 0: break;
}
}while(choice!=0);
}
/*添加学生信息模块*/
insert_message()
{ int i=sum,flag=0;
char choice;
clrscr();
printf("\n\n add data\n");
int classes;
int sex;
struct date birthday;
int age;
}students[MAX],t; /*存放N个学生纪录的结构体数组*/
/*保存信息*/
int save_message(int sum)
{
FILE *fp;
int i;
if((fp=fopen("students message.txt","wt+"))==NULL) /*貌似有问题*/
scanf("%s",inquire_name);
for(i=0;i<sum;i++)
{
if(strcmp(students[i].name,inquire_name)==0&&students[i].num!=0)
{ printf("\n --students data--\n");
PRINT1;
{
k=i;
for(j=i+1;j<sum;j++)
{ if (students[k].classes>students[j].classes)
k=j;
}
t=students[i];
students[i]=students[k];
students[k]=t;
}
printf("\n\n\n");
PRINT1;
PRINT2;
PRINT3;
}
else j++; /*要把每个students[]数组都比较了一遍*/
}
if(j==sum)
printf("\n no data!");
getchar();
return 0;
}
/*按学号查询*/
int find_by_num()
{
int i,inquire,flag;
}
/*按学生学号排序*/
sort_by_num()
{
int i,j,k;
clrscr();
for(i=0;i<sum-1;i++)
{
k=i;
for(j=i+1;j<sum;j++)
{
if (students[k].num>students[j].num)
k=j;
}
t=students[i];
students[i]=students[k];
printf("\n\n writer: \n\n");
return (0);
}*/
while(feof(fp)!=1)
{
fread(&students[i],sizeof(struct students_type),1,fp);
if(students[i].num==0) break;
else i++;
#define PRINT2 printf("number--name--class--sex--birth(yyyy-mm-dd)--age\n");
#define PRINT3 printf("%4d%5s% 6d%6d% 8d-%2d-%2d%12d\n",students[i].num,students[i].name,\
PRINT1;
PRINT2;
PRINT3;
flag=1;
}
}
if(flag==0)
{
printf("\n\n no data!");
}
getchar();
return 0;
}
/*学生信息查询*/
void inquire_message()
{ int choice;
do
{ clrscr();
printf("\n\n\n ********inquire data*******\n\n");
&students[i].birthday.day);
printf("\n age; ");
scanf("%d",&students[i].age);
i++;
k++;
}
while(i<MAX);
printf("\n ---保存学生%d的信息--\n",i);
printf(" \n返回菜单!\n");
/*清屏函数*/
void clrscr()
{
getchar();
system("cls");
}
/*出生日期结构体类型*/
struct date
{ int year;
int month;
int day;
};
/*学生结构体类型*/
struct students_type
{
int num;
char name[20];
getchar();
sum=k+sum;
save_message(sum);
return i;
}
/*浏览信息*/
read_message()
{
FILE *fp;
int i=0;
if((fp=fopen("students message.txt","rt"))==NULL)
{百度文库
printf("\n\n*****无法打开文件!*****\n");
getchar();
}*/
void sort_message()/*排序模块*/
{ int choice;
do
{ clrscr();
printf("\n\n\n **********data sort**********\n\n");
printf(" 1.ny number\n\n");
printf(" 2.by class\n\n");
students[i].classes,students[i].sex,students[i].birthday.year,\
students[i].birthday.month,students[i].birthday.day,students[i].age);
int sum; /*用来记录学生数目*/
}
fclose(fp);
return(i);
}
/*学生信息打印*/
output_message()
{
int i=0,j=0;/*,pag=1;*/
clrscr();
/*printf("\n\n --students data-- page%d\n\n",page);*/
PRINT2;
PRINT1;
/* do
clrscr();
printf("\n\n input the number:\n");
scanf("%d",&inquire);
flag=0;
for(i=0;i<sum;i++)
{
if(inquire==students[i].num&&students[i].num!=0)
{
printf("\n\n ---%s data---\n",students[i].name);
PRINT2;
PRINT1;
}
}
}
i++;
}*/
do
{
if(students[i].num!=0)
PRINT3;
PRINT1;
i++;
}
while(students[i].num!=0);
printf("any key to menu!");
save_message(sum);
getchar();
return 0;
相关文档
最新文档