您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > C语言程序设计精髓编程题在线测试
C语言程序设计精髓编程题在线测试#include#includeintmain(){intaa,bb,cc;doublere;printf(Inputmath1,Englishandmath2:);scanf(%d,%d,%d,&aa,&bb,&cc);re=(aa*5+bb*1.5+cc*3.5)/10;printf(Finalscore=%.2f\n,re);return0;}#include#includeintmain(){floatre;inti,day;printf(Inputlengthanddays:);scanf(%f,%d,&re,&day);for(i=0;i{re=re/2;}printf(length=%.5f\n,re);return0;}#include#includeintmain(){floatre;printf(Inputpaymentp:);scanf(%f,&re);re=re*0.92;printf(price=%.1f\n,re);return0;}#include#includetypedefstructclock{inthour,minute,second;}CLOCK;intmain(){CLOCKclock1,clock2;intdiff=0,hour,minute;printf(Inputtimeone(hour,second):);scanf(%d,%d,&clock1.hour,&clock1.minute);printf(Inputtimetwo(hour,second):);scanf(%d,%d,&clock2.hour,&clock2.minute);diff=abs((clock1.hour*60+clock1.minute)-(clock2.hour*60+clock2.minute));hour=floor(diff/60);minute=diff%60;printf(%dhour%dsecond\n,hour,minute);return0;}#includeintgcd(intx,inty){intr=x%y;while(r){x=y;y=r;r=x%y;}returny;}intmain(){inta,b,c,d,t;printf(Inputa/b,c/d:);scanf(%d/%d,%d/%d,&a,&b,&c,&d);if(bd){t=gcd(b,d);}else{t=gcd(d,b);}if(a*d/tc*b/t)printf(%d/%d%d/%d,a,b,c,d);elseif(a*d/t==c*b/t)printf(%d/%d=%d/%d,a,b,c,d);elseprintf(%d/%dreturn0;}#include#includeintmain(){intyear;doublecapital,rate,deposit;charn;printf(Inputrate,year,capital:);scanf(%lf,%d,%lf,&rate,&year,&capital);printf(Compoundinterest(Y/N)?);scanf(%c,&n);if(n=='n'||n=='N')deposit=capital*(1+rate*year);elsedeposit=capital*pow((1+rate),year);printf(deposit=%.4f\n,deposit);return0;}#include#includeintmain(){intyear;doublecapital,rate,deposit;charn;printf(Inputcapital,year:);scanf(%lf,%d,&capital,&year);printf(Compoundinterest(Y/N)?);scanf(%c,&n);if(year==1||year==2||year==3||year==5||year==8){switch(year){case1:rate=0.0225;break;case2:rate=0.0243;break;case3:rate=0.0270;break;case5:rate=0.0288;break;case8:rate=0.0300;break;}if(n=='n'||n=='N')deposit=capital*(1+rate*year);elsedeposit=capital*pow((1+rate),year);printf(rate=%.4f,deposit=%.4f\n,rate,deposit);}elseprintf(Erroryear!\n);return0;}#includemain(){intman,women,children;printf(ManWomenChildren\n);for(man=0;man{for(women=0;women{children=30-women-man;if(3*man+2*women+children==50){printf(%3d%8d%8d\n,man,women,children);}}}#includevoidmain(){inte[10],t,d,b,i,j,a;charOK_flag=0;for(a=10;a{d=a*a*a;b=a*a*a*a;e[0]=d/1000;e[1]=d/100%10;e[2]=d/10%10;e[3]=d%10;e[4]=b/100000;e[5]=b/10000%10;e[6]=b/1000%10;e[7]=b/100%10;e[8]=b/10%10;e[9]=b%10;for(i=0;ifor(j=i+1;jif(e[i]e[j]){t=e[i];e[i]=e[j];e[j]=t;}//if(e[]=={0,1,2,3,4,5,6,7,8,9})for(i=0;iif(e[i]==i){OK_flag=1;continue;}else{OK_flag=0;break;}if(OK_flag)printf(age=%d\n,a);}}#includeintmain(void){intyn,jn,i,count=0;printf(Inputyourbirthyear:);scanf(%d,&yn);printf(Inputthisyear:);scanf(%d,&jn);for(i=yn;i{if(i%4==0){printf(%d\n,i);count++;}}printf(count=%d\n,count);return0;}#includeintmain(void){intyn,jn,i;longunsignedcount=0;printf(Inputyourbirthyear:);scanf(%d,&yn);printf(Inputthisyear:);scanf(%d,&jn);for(i=yn;i{if(i%4==0){count=count+366*24*60*75;}elsecount=count+365*24*60*75;}}printf(Theheartbeatsinyourlife:%lu,count);return0;}#includelongFact(intn);intmain(void){inthundred,ten,one,m,n;for(hundred=1;hundred{for(ten=0;ten{for(one=0;one{m=hundred*100+ten*10+one;n=Fact(hundred)+Fact(ten)+Fact(one);if(m==n){printf(%d\n,n);}}}}return0;}longFact(intn){inti;longs=1;for(i=1;i{s*=i;}}#includeintFunc(intn);intmain(void){intn1,m1;printf(Inputn:);scanf(%d,&n1);if(n1{printf(Inputerror!\n);return0;}m1=Func(n1);printf(%d\n,m1);return0;}intFunc(intn){intys,i;for(i=n;i99;i--){if(n%i==0&&i{ys=i;break;}}returnys;}#includeintGcd(inta,intb);intmain(void){intn1,m1,n2,m2,ys;printf(Inputm,n:);scanf(%d,%d,&m1,&n1);if(m1{printf(Inputerror!\n);return0;}ys=Gcd(m1,n1);n2=n1/ys;m2=m1/ys;printf(%d/%d\n,m2,n2);return0;}intGcd(inta,intb){intys,i,temp;if(a{temp=a;a=b;b=temp;}for(i=a;i0;i--){if(a%i==0&&b%i==0){ys=i;break;}}returnys;}#includeintSumPrime(intn){inti;intk;for(i=2;i{for(k=2;k{if(i%k==0)break;}if(k==i)sum+=k;}returnsum;}intmain(void){intn;intsum;printf(Inputn:);scanf(%d,&n);sum=SumPrime(n);printf(sum=%d\n,sum);return0;}#include#includedoubleY(doublex,intn);intmain(void){intn1;doublex1,jieg;printf(Pleaseinputxandn:);scanf(%lf,%d,&x1,&n1);jieg=Y(x1,n1);printf(Result=%.2f\n,jieg);}doubleY(doublex,intn){doublesum=0;inti;for(i=0;i{sum=sqrt(sum+x);}returnsum;}#includeintSum(intn);intmain(void){intn1,jieg;printf(Pleaseinputn:);scanf(%d,&n1);if(n1{printf(dataerror!\n);return0;}else{jieg=Sum(n1);}printf(sum=%d\n,jieg);return0;}intSum(intn){intm1=0,i;for(i=n;i0;i--){m1=m1+i;returnm1;}#includeintMonkey(intn,intx);intmain(void){intn1,gs1=1,gs2;printf(Inputdaysn:);scanf(%d,&n1);gs2=Monkey(n1,gs1);printf(x=%d\n,gs2);return0;}intMonkey(intn,intx){inti,sum=1;for(i=n-1;i0;i--){sum=(sum+x)*2;}returnsum;}#includeintmain(){intc,d;floatw,p;printf(Inputpayment:);scanf(%f,&p);if(p=1000)c=10;elsec=p/100;switch(c)case0:d=0;break;case1:d=5;break;case2:case3:case4:d=8;break;case5:case6:case7:case8:case9:d=10;break;case10:d=15;break;default:printf(error);break;}w=p*(1-d/100.0);printf(p
本文标题:C语言程序设计精髓编程题在线测试
链接地址:https://www.777doc.com/doc-7845583 .html