


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1、li45300.0chang30200.0chang2、#include<stdio.h>structstudentscharsid100;charname100;floatscore3;student;voidmain()inti;floatj;printf("nPleaseinputsid:");scanf("%s",student.sid);printf("nPleaseinputname:");scanf("%s",);printf("nPleaseinpu
2、t3score:(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("naverage=%.2f",j);getc
3、h();3、#include<stdio.h>#include<string.h>#defineFsizeof(student)#defineNULL0typedefstructscoresintenglish;intmath;intc_language;intall;TP;typedefstructstudentscharsid15;charname15;TPscore;structstudents*next;student;student*input()student*head,*p1,*p2;intn=0;charch;clrscr();head=(student
4、*)malloc(F);head->next=NULL;don+;printf("nnPleaseinput%dstudentmessage:nn”,n);printf("t%dstudentsid:”,n);p1=(student*)malloc(F);p1->next=NULL;scanf("%s",p1->sid);printf("nt%dstudentname:”,n);scanf("%s",p1->name);printf("nt%dstudentscores(englesh,ma
5、th,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->next=p1;p2=p1;elsep2->next=p1;p2=p1;printf("nntttContinueorback(p
6、ressy/n):");ch=getch();while(ch='y'|ch='Y');returnhead;voidaverage1(student*head)student*p;intj;clrscr();p=head->next;while(p)j=p->score.all/3;printf("nnname:%staverage:%d",p->name,j);p=p->next;printf("nnnPressenykeyreturn.");getch();voidaverage2(
7、student*head)student*p;intn=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:%dnaveragemathis:%dnaveragec_languageis:%dt",temp1/n,temp2/n,temp3/n);student*sort(stude
8、nt*head)student*head1,*p,*q,*r;inttemp1=0,temp2=0,temp3=0,temp4;chars15,n15;head仁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>r->score.all)r=q;if(r!=p)strcpy(s,p->sid);strcpy(n,p_>name);temp1=p->score.english;temp2=p-&g
9、t;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->score.math;p->score.c_language=r->score.c_language;p->score.all=r->score.all;strcpy(r->sid,s);strcpy
10、(r->name,n);r->score.english=temp1;r->score.math=temp2;r->score.c_language=temp3;r->score.all=temp4;returnhead1;voidoutput(student*head)student*head2,*p;inti=1;clrscr();head2=sort(head);for(p=head2->next;p!=NULL;p=p->next)printf("nnname:%stsid:%stenglish:%dtmath:%dtc_langua
11、ge:%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("nnnttPressenykeyback.");getch();voidmain()student*head,*p1,*p2;inti=0,j=1;head=input();doclrscr();printf("nn(1):average1.nn(2)
12、:average2.nn(3):sort.nn(4):output.nnnPleasechoose:");scanf("%d",&i);switch(i)case1:average1(head);break;case2:clrscr();average2(head);printf("nnnPressenykeyretuen.");getch();break;case3:clrscr();p1=sort(head);for(p2=p1->next;p2!=NULL;p2=p2->next)printf("nttnam
13、e:%stmingci:%d",p2->name,j+);printf("nnnPressenykeyback.");getch();break;case4:output(head);break;default:printf("nYourchooseisnotright.");break;while(i!=-1);4、#include<stdio.h>#include<string.h>#defineNULL0#defineFsizeof(worker)typedefstructworkcharsid15;char
14、name15;intmoney;structwork*next;worker;intmin=0,max=0;chara15,b15;worker*input()worker*head,*p,*q;intn=0;charch;head=(worker*)malloc(F);head->next=0;don+;p=(worker*)malloc(F);p->next=0;printf("nntPleaseinput%dworkermessage:",n);printf("n%dworkersid:”,n);scanf("%s",p-&g
15、t;sid);printf("n%dworkername:”,n);scanf("%s",p->name);printf("n%dworkermoney:",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->m
16、oney;strcpy(a,p->name);if(p->money<min)min=p_>money;strcpy(b,p->name);q=p;printf("ntty/n");ch=getch();while(ch='y'|ch='Y');returnhead;voidoutput()clrscr();printf("nThemaxmoneyis:%dttnameis:%snn",max,a);printf("nTheminmoneyis:%dttnameis:%s"
17、,min,b);voidmain()input();output();getch();5、6、#include"stdio.h"#defineFsizeof(stu)#defineNULL0typedefstructstudentintsid;intaverage;structstudent*next;stu;stu*head;stu*create()stu*p1,*p2;intn=0;charch;head=(stu*)malloc(F);head->next=NULL;donn”,n);");n+;printf("nnPleaseinput%d
18、studentmessage:printf("t%dstudentsid:”,n);p1=(stu*)malloc(F);p1->next=NULL;scanf("%d",&p1->sid);printf("nt%dstudentaverage:",n);scanf("%d",&p1->average);if(n=1)head->next=p1;p2=p1;elsep2->next=p1;p2=p1;printf("nntttContinueorback(pressy/
19、n):ch=getch();while(ch='y'|ch='Y');returnhead;stu*select(stu*head,intx)stu*s;s=head->next;while(s)if(s->sid=x)break;s=s->next;returns;stu*insert(stu*head,intx,inty)stu*p,*r,*q;clrscr();p=head->next;r=(stu*)malloc(sizeof(stu);r->sid=x;r->average=y;if(p=NULL)/*如果插入空表*
20、/p=r;r->next=NULL;printf("ninsertsuccess!");elsewhile(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;print
21、f("ninsertsuccess!");elseif(x=p->sid)/*学号不能相同*/printf("nError->yourinputthissamesid.");else/*插到末尾*/p_>next=r;r->next=NULL;printf("ninsertsuccess!");returnhead;stu*get(stu*head,intn)/*得到位置为n的结点的指针*/stu*p;inti;p=head->next;if(n=0)returnhead;elsefor(i=1;i<
22、;n;i+)p=p->next;returnp;stu*delete(stu*head,intsid)stu*p,*q;inttemp=0,i=0;p=head->next;if(!p)printf("nlistisempty.pressenykeyback.");getch();returnhead;/*表空*/elsewhile(p)/*查找学号为sid的结点的指针*/i+;/*标记学号为sid的结点的位置*/if(p->sid=sid)temp=1;break;/*temp=1标记找到了*/p=p->next;if(temp=1)/*如果有学号
23、为sid的结点*/q=get(head,i-1);/*得到sid的前一个结点的指针*/q_>next=p->next;free(p);printf("nndeletesucess!");returnhead;else/*没有找到*/printf("nnNOthisdata.'n");returnhead;voidprint(stu*head)stu*p;p=head->next;if(!p)printf("nlistisempty.pressenykeyback.");getch();while(p)prin
24、tf("n%d:t%d",p->sid,p->average);p=p->next;main()stu*p1,*p2;charch1;intn,i=0,j=0;head=create();doclrscr();printf("n1.insert.");printf("n2.select.");printf("n3.delect.");printf("n4.printlist.");printf("n5.EXIT");printf("nchoice(
25、1-5)");ch1=getch();switch(ch1)case'1':clrscr();printf("npleaseinputinsertsid.andaverage(like1,1):");scanf("%d,%d",&i,&j);head=insert(head,i,j);printf("nnnPressenykeyback.");getch();break;case2:clrscr();printf("ninputyouwanttoseletesid:");s
26、canf("%d",&n);p1=select(head,n);if(p1)printf("nsid:%dtaverage:%d",p1->sid,p1->average);elseprintf("nNothisdata.");printf("nnnPressenykeyback.");getch();break;case3:clrscr();printf("nPleaseinputyouwantdeletesid:");scanf("%d",&n
27、);head=delete(head,n);printf("nnnPressenykeyback.");getch();break;case'4':clrscr();printf("Allinformation:");print(head);printf("nnnPressenykeyback.");getch();break;case'5':return;default:printf("nnYourenterisnotright.pressenykeyback.");getch();while(n);7、#include<stdio.h>#defineFsizeof(L)typedefstructlistchardata;structlist*next;L;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2030急救轮椅车市场投资前景分析及供需格局研究研究报告
- 2025-2030录音室耳机行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 2025-2030幻灯及投影设备产业行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030巧克力专用油行业发展分析及前景趋势与投资研究报告
- 2025-2030岩棉产业市场深度调研及发展趋势与投资研究报告
- 2025-2030小龙虾产业市场深度分析及前景趋势与投资研究报告
- 2025-2030家庭医疗设备行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030实木儿童家具行业市场发展分析及投资前景研究报告
- 2025-2030安全座椅项目可行性研究报告
- 2025-2030大容量流化床干燥器行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 一例心肌梗塞患者的病例讨论培训课件
- 机电安装总进度计划横道图
- GB∕T 13171.2-2022 洗衣粉 第2部分:试验方法
- 楷书(课件)课件
- 园林绿化工程监理实施细则(完整版)
- 工程监理部人员分工与职责
- 课程设计 CA6140拨叉说明书
- 成语故事杞人忧天PPT教案
- 部编版三年级上册音乐知识点汇总
- 生命体征的测量PPT幻灯片课件
- 吉林省吉林市高考报名登记表
评论
0/150
提交评论