发布网友 发布时间:2024-10-10 02:16
共1个回答
热心网友 时间:2024-11-08 16:41
/***第一题*/#include#includecharstr[1100];intch[1100];intmain(void){intlen,i,number,flag;if(scanf("%s",str)!=EOF)number=0;flag=0;len=strlen(str);for(i=0;i=0;i--){ch[i]*2+number>=10?flag=1:(ch[i]=(ch[i]*2)+number,number=0);if(flag){ch[i]=(ch[i]*2)-10+number;number=1;flag=0;}}if(number){printf("1");}for(i=0;iintmain(){intn,a,b,c,x,y,z,i,sum,temp;while(scanf("%d",&n)!=EOF&&n!=0){sum=0;temp=0;i=2*n;for(;i>=1;i--){scanf("%d%d%d%d%d%d",&a,&b,&c,&x,&y,&z);if(i%2!=0)sum+=(a*b+c*x+y*z);elsetemp+=(a*b+c*x+y*z);}if(sum==temp)printf("iwilldobetternexttime\n");elseif(sum>temp)printf("acmisontheway!\n");elseprintf("acmisNo.1!!\n");}return0;}/***第三题*/#include#defineN1000000intjiecheng(intn){intnum=1;inti;for(i=0;iN)num%=N;}returnnum;}intmain(void){intn;inti;intsum;doublesum1;while(scanf("%d",&n)==1&&n!=0){sum=0;sum1=0.0;for(i=0;iN)sum%=N;printf("%d\n",sum);}return0;}/***第四题*/#includeintmain(void){intn,count;while(scanf("%d",&n)==1&&n!=0){//当输入数据为零时程序结束count=0;while(n!=1){if(n%2==0){n/=2;count++;}else{n=n*3+1;count++;}}printf("%d\n",count);}return0;}//这个程序在我这里运行没有问题,不知道你那里出现了什么问题,我用的是VC6.0/***第五题*/intsingle(intnumber){inta,sum=0;while(number!=0){a=number%10;number/=10;sum+=a;}returnsum<10?sum:single(sum);}intmain(void){intnumber,result;while(scanf("%d",&number)==1&&number!=0){//当输入数据为零时程序结束result=single(number);printf("%d\n",result);}return0;}//这个程序在我这边运行没有问题,不知道你所谓的超时是什么意思?