您好,欢迎访问三七文档
当前位置:首页 > 建筑/环境 > 工程监理 > 第四、五、六届全国ITAT教育工程就业技能大赛c语言复赛
第四届全国ITAT教育工程就业技能大赛复赛试题C语言程序设计(A卷)1、编写一个程序,让它有以下功能:从键盘上输入一个五位数,对此整数中的五个数值进行从大到小排序,形成一个新的五位数,输出这个整数。(15分)#includestdio.hintfun(intn){intnum=0,t;inta[5],i,j;for(i=0;i5;i++){a[i]=n%10;n/=10;}for(i=0;i4;i++)for(j=i+1;j5;j++)if(a[j]a[i]){t=a[i];a[j]=a[i];a[i]=t;}for(i=0;i5;i++)num=a[i]+num*10;returnnum;}voidmain(){inta,b;scanf(%d,&a);b=fun(a);printf(%d\n,b);}2、输入年、月、日,输出该日期是该年的第几天。(25分)#includestdio.hintchoice(intyear){intflag=0;if((year%400==0)||(year%100!=0&&year%4==0))flag=1;returnflag;}intyue(intmoonth,intflag){intyue;switch(moonth){case1:case3:case5:case7:case8:case10:case12:yue=31;break;case2:switch(flag){case0:yue=28;break;case1:yue=29;break;}break;case4:case6:case9:case11:yue=30;break;}returnyue;}voidmain(){intnum=0,flag,i;intyear,moonth,data;printf(Pleaseinputadata:like1991,6,6\n);scanf(%d,%d,%d,&year,&moonth,&data);flag=choice(year);for(i=1;imoonth;i++)num+=yue(i,flag);num+=data;printf(%d\n,num);}3、利用数组实现数据的存储。将学生的学号和成绩存储在数组中,利用循环计算出数组中存储学生的平均成绩,找出高于平均分的学生信息并输出。(20分)#includestdio.hvoidmain(){intstdnum[100];intstdgrade[100];inti,num;intavg=0;printf(Pleaseinputtheclass'studentnumber\n);scanf(%d,&num);printf(Pleaseinputstudent'snumberandgrade!\n);for(i=0;inum;i++){scanf(%d,%d,&stdnum[i],&stdgrade[i]);avg=stdgrade[i]+avg;}avg=avg/num;printf(%d\n,avg);for(i=0;inum;i++)if(stdgrade[i]avg)printf(%d,%d\n,stdnum[i],stdgrade[i]);}4、输入五个国家的名字,按字母顺序(即按ASCII码从小到大的顺序)排列输出。(20分)/*Note:YourchoiceisCIDE*/#includestdio.h#includestring.hvoidsort(charname[5][20],intn){chartemp[20];inti,j;for(i=0;in-1;i++){for(j=i+1;jn;j++)if(strcmp(name[i],name[j])0){//temp=name[i];//name[i]=name[j];//name[j]=temp;strcpy(temp,name[i]);strcpy(name[i],name[j]);strcpy(name[j],temp);}}}voidprint(charname[5][20],intn){inti;for(i=0;in;i++)printf(%s\n,name[i]);}voidmain(){charp[5][20];//={Followme,BASIC,GreatWall,FORTRAN,Computerdesign};inti,n=5;printf(Pleaseinputfivecountry'snames\n);for(i=0;i5;i++)gets(p[i]);//scanf(%s,%s,%s,%s,%s,p[0],p[1],p[2],p[3],p[4]);sort(p,5);print(p,5);}5、用指针实现:任意输入20个数,将它们按照从大到小的顺序输出。(20分)#includestdio.hvoidmain(){int*p,a[20];inti,j,temp;printf(Pleaseinput20internumber!\n);for(i=0;i20;i++)scanf(%d,,&a[i]);p=a;for(i=0;i19;i++)for(j=i+1;j20;j++)if(p[i]p[j]){temp=p[i];p[i]=p[j];p[j]=temp;}for(i=0;i20;i++)printf(%d\n,*(p++));}附加题6、编写一个简单的通讯录管理系统。通讯录包括:姓名、通讯地址、邮编、联系电话,现编写一个通讯录管理系统,可以对通讯录进行输入、显示、查找,通讯录保存到一个文件中。(50分)(提示:可能用到以下库函数:malloc(),功能:分配size字节的存储区,用法:(类型*)malloc(size*sizeof(你要定义的类型));包含于stdlib.h库中feof(),功能:检测文件是否结束用法:intfeof(fp)FILE*fp;包含于stdio.h库中。)/***********************************************6、编写一个简单的通讯录管理系统。通讯录包括:姓名、通讯地址、邮编、联系电话,现编写一个通讯录管理系统,可以对通讯录进行输入、显示、查找,通讯录保存到一个文件中。(50分)(提示:可能用到以下库函数:malloc(),功能:分配size字节的存储区,用法:(类型*)malloc(size*sizeof(你要定义的类型));包含于stdlib.h库中feof(),功能:检测文件是否结束用法:intfeof(fp)FILE*fp;包含于stdio.h库中。)************************************************//*Note:YourchoiceisCIDE*/#includestdio.h#includestring.h#includestdlib.htypedefstruct{charname[20];charadress[30];charcode[10];charphonenumber[15];}STD;voidinit(){printf(欢迎光临通讯录管理系统\n);printf(输入请选择:1\n);printf(显示请选择:2\n);printf(查找请选择:3\n);printf(退出请选择:0\n);printf(请输入您的选择:);}voidstop(){exit(0);}voidinput(){STDtemp;FILE*fp;if((fp=fopen(F:\\story\\from.txt,a))==NULL){printf(打开文件出现错误!\n);return;}printf(请输入姓名:);scanf(%s,temp.name);printf(请输入通讯地址:);scanf(%s,temp.adress);printf(请输入邮编:);scanf(%s,temp.code);printf(请输入联系电话:);scanf(%s,temp.phonenumber);printf(输入记录为:);printf(%s%s%s%s\n,temp.name,temp.adress,temp.code,temp.phonenumber);fprintf(fp,%s%s%s%s\n,temp.name,temp.adress,temp.code,temp.phonenumber);fclose(fp);}voiddisplay(){STDtemp;FILE*fp;//intc;if((fp=fopen(F:\\story\\from.txt,r))==NULL){printf(打开文件出现错误!\n);return;}printf(姓名通讯地址邮编联系电话\n);fscanf(fp,%s%s%s%s,temp.name,temp.adress,temp.code,temp.phonenumber);while(!feof(fp)){printf(%10s%10s%10s%20s\n,temp.name,temp.adress,temp.code,temp.phonenumber);fscanf(fp,%s%s%s%s,temp.name,temp.adress,temp.code,temp.phonenumber);}fclose(fp);}voidfind(){charch[20];STDtemp;FILE*fp;printf(请输入查找人的姓名:);scanf(%s,ch);if((fp=fopen(F:\\story\\from.txt,r))==NULL){printf(打开文件出现错误!\n);return;}while(1){fscanf(fp,%s%s%s%s,temp.name,temp.adress,temp.code,temp.phonenumber);strlwr(temp.name);strlwr(ch);if(strcmp(temp.name,ch)==0){printf(您找的人的信息如下:\n);printf(%s%s%s%s\n,temp.name,temp.adress,temp.code,temp.phonenumber);break;}if(feof(fp)){printf(对不起,没有找到您需要的资料!\n);break;}}fclose(fp);}voidmain(){intchoice;while(1){init();scanf(%d,&choice);//printf(%d\n,choice);switch(choice){case0:stop();break;case1:input();break;case2:display();break;case3:find();break;default:printf(输入错误,请您重新选择\n);break;}}}第五届全国ITAT教育工程就业技能大赛复赛试题C语言程序设计(A卷)1、编程解决如下数学问题:有12升水,怎样利用一个8升和一个5升的容器将水分为两个6升?要求以如下格式打印出分水步骤。(20分)a12b8c51200***(“*”表示当前状态下每个容器的盛水量)......066#includestdio.hvoidmain(){printf(a12b8c5\n);printf(1200\n);printf(480\n);printf(435\n);printf(930\n);printf(903\n);printf(183\n);printf(165\n);printf(660\n);}2、编程实现:有二维数组a[3][3]={{5.4,3.2,8},{6,4,3.3},{7,3,1.3}},将数组a的每一行元素均除以该行上的主对角元素(第1行同除以a[0][0],第2行同除以a[1][1],...),按行输出新数组。(20分)#
本文标题:第四、五、六届全国ITAT教育工程就业技能大赛c语言复赛
链接地址:https://www.777doc.com/doc-204558 .html