分享
 
 
 

用 c编写的一个学生成绩管理系统

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

//包含了文件头#include "cstdilb"能在VC中编译成功,没有的话就只能在tc2.0中编译成功 //该程序只是我学习过程中自己练习的,各位观众不要见笑,对出学c的同学应该会有所帮助 #include "stdio.h"

#include "conio.h"

#include "string.h"

#include "cstdlib"

#define Null 0

struct node

{ int member;

int number;

char name[10];

char sex[5];

struct node *next;

};

struct node *creatlink() /*CREAT LINK*/

{

int x;

struct node *head,*q,*p;

head=q=Null;

printf ("Enter data (if the member's vale<0 the program end)\n");

printf ("Plaese enter a x's vale: ");

scanf ("%d",&x);

printf ("\n");

p=(struct node*)malloc(sizeof(struct node));

if (!p)exit(0);

p->member=x; if (x<0)

{

printf ("The program is end haha!!\n");

exit(0);

}

printf ("Plaese enter a number's vale: ");

scanf ("%d",&p->number);

printf ("\n");

p->next=Null;

head=p;

q=p;

printf ("Plaese enter a x's vale: " );

scanf ("%d",&x);

printf ("\n");

while (x>=0)

{

p=(struct node*)malloc(sizeof(struct node));

if (!p)exit(0);

p->member=x;

printf ("Plaese enter a number's vale: ");

scanf ("%d",&p->number);

printf ("\n");

q->next=p;

p->next=Null;

q=p;

printf ("Plaese enter a x's vale: ");

scanf ("%d",&x);

printf ("\n");

if (x<0)

printf ("The program is end haha!!\n"); }

return(head); }

void writename(struct node *h) /*WRITE NAME*/

{

struct node *search;

search=h;

while(search!=Null) /*当search指针不是空时*/

{

printf ("--------------------------------------------\n");

printf ("Plaese enter a name: ");

scanf ("%s",search->name);

printf("\n");

search=search->next;

}

}

void writesex(struct node *h) /*WRITE SEX*/

{ struct node *search;

search=h;

while (search!=Null) /*当search指针不是空时*/

{

printf ("----------------------------------------\n");

printf ("Plaese enter a sex to this man or woman: ");

scanf ("%s",search->sex);

printf ("\n");

search=search->next;

}

}

void putlink(struct node *h) /*PUT LINK*/

{

struct node *search;

search=h;

while (search)

{

printf ("----------------------------------------------------------------");

printf("\n");

printf("%d,%d,%s,%s",search->member,search->number,&search->name,&search->sex);

printf ("\n");

search=search->next;

}

} int mm(int n) /*递归调用*/

{

if (n<1||n>3) /*如果n的值大于3或小于1就是错误的输入*/

{

printf ("You make a error chooes !\n");

printf ("Make a right chooes : ");

scanf ("%d",&n);

mm(n);

printf ("\n"); }

return(n);

}

void insertele(struct node *h) /*INSRET ELEMENT*/

{

struct node *search,*befores,*newele;

int m,s;

search=befores=h;

newele=(struct node *)malloc(sizeof(struct node)); /*开辟一个新接点空间*/

printf ("--------------------------------------------\n");

if (!newele) /*判断是否分配成功*/

{

printf ("The newelement'mallocing falled ! \n");

exit(0);

}

else

{

printf ("--------------------------------------------\n");

printf ("Please enter new data to the newelement \n");

scanf ("%d,%d,%s,%s",&newele->member,&newele->number,&newele->name,&newele->sex); /*输入新链表的数据*/

}

printf ("-------------------------------------------------\n");

printf ("Please choose a way to insert your new elsement :\n(* if you choose 1,you can enter 1,2 enter 2........)\n1 is the member way,2 is the number way,3 is the name way\n");

printf ("Please enter way's vale(you only can enter a int vale>0and<4:" );

scanf ("%d",&m);

s=mm(m); /*递归调用*/ printf ("\n-----------------------------------------------\n");

switch(s)

{

case 1: /*按序列号插入*/

{

while(search!=Null&&(search->member<=newele->member))

{

befores=search;

search=search->next;

}

befores->next=newele;

newele->next=search; };

break;

case 2: /*按数值大小插入*/

{

while(search!=Null&&(search->number<=newele->number))

{

befores=search;

search=search->next;

}

befores->next=newele;

newele->next=search;

};

break;

case 3: /*按姓名插入*/

{

while(search!=Null&&(strcmp(search->name,newele->name)<0))

{

befores=search;

search=search->next;

}

befores->next=newele;

newele->next=search;

};

break; }

printf ("%d,%d,%s,%s\n",newele->member,newele->number,&newele->name,&newele->sex);

}

struct node *delelink(struct node *h) /*DELETE LINK*/

{

struct node *search,*befores;

int member;

printf ("This program's funcation is to delete a member which you want \n");

printf ("Plaese enter a member which you want to delete : ");

scanf ("%d",&member);

printf ("\n");

search=h;

if ((h->member==member)&&h)

{

h=search->next;

free(search); }

while ((search->member!=member)&&search)

{

befores=search;

search=search->next; }

if ((search->member==member)&&search)

{

befores->next=search->next;

free(search);

} return(h); /*把头指针传给putlink函数,此函数从头指针开始输出数据*/

}

int main()

{

struct node *H,*h;

printf (" Now,let's creat a link ,hahaha!!!\n\n");

H=creatlink(); /*建立一个链表并输入每个元素的编号以及一个属于该元素的一个数据*/

writename(H) ; /*输入每个元素的姓名*/

writesex(H); /*输入每个元素的性别*/

printf ("--------------------------------------------------------------------------\n");

printf (" Now,let's put this link out !!\n\n");

putlink(H); /*打印原始链表*/

printf("---------------------------------------------------------------------------\n");

printf ("Now let's insert a element !\n");

printf ("--------------------------------------------------------------------------\n");

insertele(H); /*插入一个新的元素*/

printf ("Now let's put out this new link !\n");

putlink(H);

printf ("---------------------------------------------------------------------------\n");

printf("Now,let's delete a member!!!\n\n");

h=delelink(H); /*删除一个元素*/

printf("\n");

printf ("--------------------------------------------------------------------------\n"); printf ("put out the link again!\n");

putlink(h); /*打印删除一个元素后的链表*/

printf ("\n------------------------------------------------------------------------\n the program is end !\n press any key to continue !!\n\n\n\n\n\n\n\n\n");

getch();

return 0;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有