版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1、li45300.0chang 30200.0chang2、#include<stdio.h>struct studentschar sid100;char name100;float score3;student;void main()int i; float j;printf("nPlease input sid:");scanf("%s",student.sid);printf("nPlease input name:");scanf("%s",);printf(&quo
2、t;nPlease input 3 score:(like1,1,1)");/* 输入逗号隔开*/scanf("%f,%f,%f",&student.score0,&student.score1,&student.score2);printf("nsid = %s",student.sid);printf("nname = %s",);j=(student.score0+student.score1+student.score2)/3.0;printf("navera
3、ge = %.2f",j);getch();3、#include<stdio.h>#include<string.h>#define F sizeof(student)#define NULL 0typedef struct scoresint english;int math;int c_language;int all;TP;typedef struct studentschar sid15; char name15;TP score;struct students *next;student;student *input()student *head,*
4、p1,*p2;int n=0;char ch;clrscr();head=(student *)malloc(F);head->next=NULL;don+;printf("nnPlease input %d student message:nn",n);printf("t%d student sid:",n);p1=(student *)malloc(F);p1->next=NULL;scanf("%s",p1->sid);printf("nt%d student name:",n);scanf
5、("%s",p1->name);printf("nt%d student scores(englesh,math,c_language):",n);scanf("%d,%d,%d",&p1->score.english,&p1->score.math,&p1->score.c_language); p1->score.all=p1->score.english+p1->score.math+p1->score.c_language; if(n=1) head-&g
6、t;next=p1;p2=p1; elsep2->next=p1;p2=p1;printf("nntttContinue or back (press y/n):");ch=getch();while(ch='y'|ch='Y');return head;void average1(student *head)student *p;int j;clrscr();p=head->next;while(p) j=p->score.all/3;printf("nnname:%staverage: %d",p-&
7、gt;name,j);p=p->next;printf("nnnPress eny key return.");getch();void average2(student *head)student *p;int n=0,temp1=0,temp2=0,temp3=0;p=head->next;while(p)temp1+=p->score.english;temp2+=p->score.math;temp3+=p->score.c_language;p=p->next;n+;printf("nnaverageenglishis
8、:%dnaveragemathis:%dnaveragec_languageis : %dt",temp1/n,temp2/n,temp3/n);student *sort(student *head)student *head1,*p,*q,*r; int temp1=0,temp2=0,temp3=0,temp4; char s15,n15; head1=head;for(p=head1->next;p->next!=NULL;p=p->next)r=p; for(q=p->next;q;q=q->next)if(q->score.all>
9、;r->score.all) r=q;if(r!=p)strcpy(s,p->sid);strcpy(n,p->name); temp1=p->score.english; temp2=p->score.math; temp3=p->score.c_language; temp4=p->score.all; strcpy(p->sid,r->sid);strcpy(p->name,r->name); p->score.english=r->score.english;p->score.math=r->sc
10、ore.math; p->score.c_language=r->score.c_language; p->score.all=r->score.all;strcpy(r->sid,s);strcpy(r->name,n);r->score.english=temp1;r->score.math=temp2;r->score.c_language=temp3;r->score.all=temp4;return head1;void output(student *head)student *head2,*p;int i=1; clrs
11、cr(); head2=sort(head);for(p=head2->next;p!=NULL;p=p->next)printf("nnname: %stsid: %stenglish: %dtmath: %dtc_language: %dtaverage: %dtmingci: %d ",p->name,p->sid,p->score.english,p->score.math,p->score.c_language,p->score.all/3,i+);average2(head);printf("nnnttP
12、ress eny key back.");getch();void main()student *head,*p1,*p2; int i=0,j=1;head=input();doclrscr();printf("nn(1):average1.nn(2):Please choose:");scanf("%d",&i);switch(i)case 1: average1(head);break;case 2: clrscr();average2(head);average2.nn(3):printf("nnnPresssort.
13、nn(4):output.nnneny keyretuen.");getch();break;case 3: clrscr();p1=sort(head); for(p2=p1->next;p2!=NULL;p2=p2->next) printf("nttname: %stmingci:%d",p2->name,j+);printf("nnnPress eny key back.");getch(); break;case 4: output(head);break;default: printf("nYour ch
14、oose is not right.");break;while(i!=-1);4、#include<stdio.h>#include<string.h>#define NULL 0#define F sizeof(worker)typedef struct workchar sid15; char name15; int money;struct work *next;worker;int min=0,max=0;char a15,b15;worker *input()worker *head,*p,*q;int n=0; char ch;head=(wor
15、ker *)malloc(F); head->next=0; don+;p=(worker *)malloc(F); p->next=0;printf("nntPlease input %d worker message : ",n); printf("n%d worker sid: ",n);scanf("%s",p->sid); printf("n%d worker name: ",n);scanf("%s",p->name); printf("n%d wo
16、rker money: ",n);scanf("%d",&p->money); if(n=1)head->next=p; q=p;max=p->money;strcpy(a,p->name);min=p->money;strcpy(b,p->name);elseq->next=p;if(p->money>max) max=p->money;strcpy(a,p->name); if(p->money<min) min=p->money;strcpy(b,p->name
17、);q=p;printf("ntty/n");ch=getch();while(ch='y'|ch='Y');return head;void output()clrscr();printf("nThe max money is:printf("nThe min money is:%dttname is: %snn",max,a);%dttname is: %s",min,b);void main()input();output();getch();5、 6、#include"stdio.h&
18、quot;#define F sizeof(stu)#define NULL 0typedef struct studentint sid;int average;struct student *next;stu;stu *head;stu *create()stu *p1,*p2;int n=0;char ch;head=(stu *)malloc(F);head->next=NULL;don+;printf("nnPlease input %d student message:printf("t%d student sid:",n);p1=(stu *)
19、malloc(F);p1->next=NULL;scanf("%d",&p1->sid);printf("nt%d student average:",n);scanf("%d",&p1->average);if(n=1)nn",n); head->next=p1;p2=p1; elsep2->next=p1;p2=p1;printf("nntttContinue or back (press y/n):");ch=getch();while(ch='
20、y'|ch='Y');return head;stu *select(stu *head,int x)stu *s;s=head->next;while(s)if(s->sid=x)break;s=s->next;return s;stu *insert(stu *head,int x,int y)stu *p,*r,*q;clrscr();p=head->next;r=(stu *)malloc(sizeof(stu);r->sid=x;r->average=y;if(p=NULL)/*如果插入空表*/p=r;r->next=
21、NULL;printf("ninsert success!");else会跳出循环)while(x>p->sid)/* 找到插入的位置,按学号大小。*/if(p->next=NULL)break; p=p->next;if(x<p->sid)/* 插到中间位置*/(找到位置或者到了表尾都r->sid=p->sid; r->average=p->average; p->sid=x; p->average=y; r->next=p->next; p->next=r;printf("
22、;ninsert success!");else if(x=p->sid)/* 学号不能相同*/printf("nError->your input this same sid.");else/* 插到末尾 */p->next=r; r->next=NULL; printf("ninsert success!");return head;stu *get(stu *head,int n)/* 得到位置为n 的结点的指针*/stu *p;int i; p=head->next;if(n=0)return head;e
23、lsefor(i=1;i<n;i+) p=p->next; return p;stu *delete(stu *head,int sid)stu *p,*q;int temp=0,i=0;p=head->next;if(!p)printf("nlist is empty.press eny key back.");getch();return head;/*表空 */elsewhile(p)/* 查找学号为sid 的结点的指针*/i+;/*标记学号为sid的结点的位置*/if(p->sid=sid)temp=1;break; /*temp=1标记找到
24、了*/p=p->next;if(temp=1) /* 如果有学号为sid 的结点 */q=get(head,i-1);/* 得到 sid 的前一个结点的指针q->next=p->next;free(p);printf("nndelete sucess !");return head;*/else/* 没有找到 */printf("nnNO this data.n");return head;void print(stu *head)stu *p;p=head->next;if(!p)printf("nlist is em
25、pty. press eny key back.");getch(); while(p)printf("n%d :t%d ",p->sid,p->average);p=p->next;main()stu *p1,*p2;char ch1;int n,i=0,j=0;head=create();doclrscr();printf("n1. insert.");printf("n2. select.");printf("n3. delect.");printf("n4. print
26、 list.");printf("n5. EXIT");printf("n.choice (1-5).");ch1=getch();switch(ch1)case '1': clrscr();printf("nplease input insert sid. and average(like 1,1):");scanf("%d,%d",&i,&j);head=insert(head,i,j);printf("nnnPress eny key back."
27、);getch();break;case '2': clrscr();printf("ninput you want to selete sid:");scanf("%d",&n);p1=select(head,n);if(p1) printf("nsid:%dtaverage:%d",p1->sid,p1->average);elseprintf("nNo this data.");printf("nnnPress eny key back.");getch
28、();break;case'3':clrscr();printf("nPlease input you want delete sid:scanf("%d",&n);head=delete(head,n);printf("nnnPress eny key back.");getch();break;");case'4': clrscr();printf("All information :");print(head);printf("nnnPress eny key back.");getch();break;case '5': return;default: printf("nnYour enter is not right.press eny key back.");getch();while(n);7、#include<stdio.h>#define F sizeof(L)typedef struct listchar data; struct list *next;L;L *set_l
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司新员工转正工作个人总结
- 传统餐饮老字号品牌现状
- 人际交往中的十大心理效应
- 脑梗死后遗症合并肺部感染护理查房
- 糖尿病患者的护理查房
- 金融消费者权益保护实施方案
- 2025-2026学年湖南省湘潭市高三(最后冲刺)历史试卷含解析
- 初中历史重大事件混合式学习模式中数字化教育资源的个性化设计与历史理解教学研究课题报告
- 新能源储能电站商业模式创新与储能设备智能化监控可行性研究
- 影像组学在肿瘤个体化治疗中的精准医疗实践
- T-CHAS 10-2-19-2023 中国医院质量安全管理 第2-19部分:患者服务 内镜治疗
- 2025年农产品质量与安全管理试卷及答案
- DB11∕T 1072-2025 城市桥梁工程施工质量检验标准
- 中国农业大学强基计划真题笔试
- 2025年公安院校联考考试面试试题及答案
- 雨课堂学堂云在线《经典与思考-人文清华大师面对面 》单元测试考核答案
- 2025年6月浙江省高考历史试卷真题(含答案解析)
- 《婴幼儿游戏活动实施》课程标准(五年制高职专科)
- 车载光通信专题学习
- 四级手术术前多学科讨论制度(2025年)
- 2025年贵州贵阳事业单位招聘考试卫生类医学检验专业知识试卷
评论
0/150
提交评论