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

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

#include

#include

#include

#include

struct stuType

{

char name[9]; //姓名

char gender[3]; //性别

int age; //年龄

char phone[11]; //手机号

int stature; //身高

}stud[100]; //;不可少

/**********************************************/

void GotoXY(int x, int y);

void shuru();

void zhuye();

void chaxun();

void chaxunsx();

void chaxun_name();

void chaxunlb();

void chaxunxm1();

void chaxunxm2();

void displist();

void change();

void sort();

void sort_age();

void sort_stature();

void statistics();

/************************************************/

void main()//主函数

{

zhuye();//系统首页

}

/************************************************/

void GotoXY(int x, int y)//坐标定位函数

{

COORD c;

c.X = x - 1;

c.Y = y - 1;

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);

}

/*******************控制输入的函数*****************************/

void shuru()

{

int gdok;

int nmOk;

int ageok;

int stok;

char keypress;

FILE *fp;

if((fp=fopen("stuType", "a"))==NULL)

{

printf("cannot open file\n");

return;

}

GotoXY(30,3);

printf("请顺序输入各项信息");

GotoXY(5,4);

printf("================================================================ ===");

GotoXY(5,6);

printf("姓名: 性别: 年龄: 手机号码: 身高(cm): ");

for(int i=0; i<100; i++)

{

nmOk=false;

while(!nmOk)

{

GotoXY(10,6);

scanf("%s",stud[i].name);

if(stud[i].name=='\0')

{

GotoXY(10,8);

printf("名字不能为空,按任意键继续...");

GotoXY(10,8);

printf(" ");

getche();

GotoXY(10,8);

printf(" ");

}

else

{

nmOk=true;

}

}

gdok=false;

while(!gdok)

{

GotoXY(25,6);

scanf("%s",stud[i].gender);

if(stud[i].gender=='\0')

{

GotoXY(10,9);

printf("性别不能为空,按任意键继续...");

GotoXY(10,9);

printf(" ");

getche();

GotoXY(10,9);

printf(" ");

}

else

{

gdok=true;

}

}

ageok=false;

while(!ageok)

{

GotoXY(34,6);

printf(" ");

GotoXY(34,6);

scanf("%d",&stud[i].age);

if(stud[i].age>100||stud[i].age<0)

{

GotoXY(10,9);

printf("年龄必须为0到100的整数,按任意键继续...");

getche();

GotoXY(10,9);

printf(" ");

}

else

{

ageok=true;

}

}

GotoXY(47,6);

scanf("%s",stud[i].phone);

stok=false;

while(!stok)

{

GotoXY(71,6);

printf(" ");

GotoXY(71,6);

scanf("%d",&stud[i].stature);

if(stud[i].stature>230||stud[i].stature<50)

{

GotoXY(10,9);

printf("身高必须为50到230的数,按任意键继续...");

getche();

GotoXY(10,9);

printf(" ");

}

else

{

stok=true;

}

}

if(fwrite(&stud[i], sizeof(struct stuType), 1, fp)!=1)

printf("file write error\n");

fclose(fp);

GotoXY(10,9);

printf("是否继续添加信息(Y/N)");

scanf("%s",&keypress);

if(keypress=='N'||keypress=='n')

相关文档
最新文档