欢迎来到天天文库
浏览记录
ID:41603495
大小:44.50 KB
页数:5页
时间:2019-08-28
《C语言程序设计决赛试题答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、平顶山学院软件学院10级软工二班C语言程序设计决赛试题注:个人作品,仅供参考第一届5题:#includeintmain(){intx=1,y=1,z=1,q=1;for(x=1;x<10;x++)for(y=1;y<=12;y++)for(z=1;z<=23;z++)for(q=1;q<=44;q++)if(x+y+z+q==30&&50*x+20*y+10*z+5*q==500)printf("50元:%d张;20元:%d张;10元:%d张;5元:%d张",x,y,z,
2、q);return0;}第一届6题:#include#includevoidjisuan(intn){intsum=0;floats=0;for(inti=0;i3、stdio.h>intmain(){5平顶山学院软件学院10级软工二班C语言程序设计决赛试题ints=21,i=0;while(s!=1){while(1){printf("Howmanystickdoyouwanttake(1~4)?");scanf("%d",&i);if(i>44、5、i<0)printf("Inputerror!Pleaseinputagain!");elsebreak;}s=s-i;i=5-i;printf("%dstickleftinthepile.Computertank%d6、stick.",s,i);s=s-i;if(s!=1)printf("%dstickleftinthepile.",s);}while(1){printf("%dstickleftinthepile.",s);printf("Howmanystickdoyouwanttake(1~4)?");scanf("%d",&i);if(i==1)break;elseprintf("Inputerror!");}printf("Youhavetakethelaststick!***Youlose!7、n");printf(">>---------------GameOver!-------------------");return0;}第四届2题:商人过河#include#includevoidtitou(){for(intr=0;r<80;r++)printf("*");inti=2;printf("tttt%c",i);printf("Welcomecometothegame!");printf("%c",i);printf("GameRules8、:");printf("3mentake3retainersandgoodstppasstherever,theboatcarrys2personseachtime.Inpassingtherever,atanybanknumberofmenmustbemorethanthenumbverofthe5平顶山学院软件学院10级软工二班C语言程序设计决赛试题retainers,ortheretainerswillokillthemenandtakethegoods.");printf("Gam9、eoperations:(1)Inputthenumofmenandretainersinturn;");printf("(2)Inputerrorkeys,thegamewillrestart.");for(r=0;r<80;r++)printf("*");}intguohe(){chars1[]="men",s2[]="retainers";intm=3,r=3,m1=0,r1=0,a=0,b=0,i=0,p=0,c=0;//m、r、m1、r1为两岸商人仆从人数;i用于控制循环;a、b为登船人数;10、p为船上人数;c为船返回是驾船者charx;while(1){system("cls");titou();printf("Thisbank:ttttThatbank:");for(i=0;i
3、stdio.h>intmain(){5平顶山学院软件学院10级软工二班C语言程序设计决赛试题ints=21,i=0;while(s!=1){while(1){printf("Howmanystickdoyouwanttake(1~4)?");scanf("%d",&i);if(i>4
4、
5、i<0)printf("Inputerror!Pleaseinputagain!");elsebreak;}s=s-i;i=5-i;printf("%dstickleftinthepile.Computertank%d
6、stick.",s,i);s=s-i;if(s!=1)printf("%dstickleftinthepile.",s);}while(1){printf("%dstickleftinthepile.",s);printf("Howmanystickdoyouwanttake(1~4)?");scanf("%d",&i);if(i==1)break;elseprintf("Inputerror!");}printf("Youhavetakethelaststick!***Youlose!
7、n");printf(">>---------------GameOver!-------------------");return0;}第四届2题:商人过河#include#includevoidtitou(){for(intr=0;r<80;r++)printf("*");inti=2;printf("tttt%c",i);printf("Welcomecometothegame!");printf("%c",i);printf("GameRules
8、:");printf("3mentake3retainersandgoodstppasstherever,theboatcarrys2personseachtime.Inpassingtherever,atanybanknumberofmenmustbemorethanthenumbverofthe5平顶山学院软件学院10级软工二班C语言程序设计决赛试题retainers,ortheretainerswillokillthemenandtakethegoods.");printf("Gam
9、eoperations:(1)Inputthenumofmenandretainersinturn;");printf("(2)Inputerrorkeys,thegamewillrestart.");for(r=0;r<80;r++)printf("*");}intguohe(){chars1[]="men",s2[]="retainers";intm=3,r=3,m1=0,r1=0,a=0,b=0,i=0,p=0,c=0;//m、r、m1、r1为两岸商人仆从人数;i用于控制循环;a、b为登船人数;
10、p为船上人数;c为船返回是驾船者charx;while(1){system("cls");titou();printf("Thisbank:ttttThatbank:");for(i=0;i
此文档下载收益归作者所有