2、;printf("n^3=%d",k);for(i=1;ivoidmain(){inta,b,c,x,y,z;for(a=0;a<=9;a++){for(b=0;b<=9;b++){for(c=0;c<=9;c++){x=a*100+b*10+c;y=c*100+b*10+a;z=x+y;if(z==1333)p
3、rintf("a=%d,b=%d,c=%d",a,b,c);}}}}3.耶稣有13个门徒,其中有一个就是出卖耶稣的叛徒,请用排除法找出这位叛徒:13人围坐一圈,从第一个开始报号:1,2,3,1,2,3……,凡是报到“3”就退出圈子,最后留在圈内的人就是出卖耶稣的叛徒,请找出它原来的序号。解:#includevoidmain(){inti,j,k,f,v,x,o;intnumbers[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};inttwo[13];intth
4、ree[13];intfour[13];intfive[13];intsix[13];for(i=0;i<=12;i++){for(j=1;j<=11;j++){if(i==12)two[0]=numbers[12];elseif(numbers[i]%3!=0)two[j]=numbers[i];elsenumbers[i]=0;}}for(j=0;j<=12;j++){for(k=0;k<=12;k++){if(j==0)three[0]=two[0];elseif(j%3!=0)three[k]=tw
5、o[j];elsetwo[j]=0;}}for(k=0;k<=12;k++){for(f=0;f<=12;f++){if(k==0)four[0]=three[0];elseif(k%3!=0)four[f]=three[k];elsethree[k]=0;}}for(f=0;f<=12;f++){for(v=1;v<=11;v++){if(f==0)five[1]=four[0];elseif(f==3)five[0]=four[3];elseif(f%3!=0)five[v]=four[f];elsef
6、our[f]=0;}}for(v=0;v<=12;v++){for(x=0;x<=12;x++){if(v==0)six[0]=five[0];elseif(v%3!=0)six[x]=five[v];elsesix[x]=0;}}printf("那个叛徒的原来序号就是:%d",three[0]);}4.输入一个五位以内的正整数,(1)判断它是一个几位数;(2)请按序输出其各位数字;(3)逆序输出其各位数字。如输入:56439,输出:5位数5,6,4,3,99,3,4,6,5解:#include"std
7、io.h"voidmain(){inti,j,k,h,f,m,t;printf("Pleaseenterawithinfiveoftheinteger:");scanf("%d",&i);if(i/10000!=0){printf("5位数");j=i/10000;t=i%10000;k=t/1000;t=t%1000;h=t/100;t=t%100;f=t/10;m=t%10;printf("%d%,d%,d%,%d,%d",j,k,h,f,m);printf("%d%,d%,d%,%d,%d
8、",m,f,h,k,j);}elseif(i/1000!=0){printf("4位数");k=i/1000;t=i%1000;h=t/100;t=t%100;f=t/10;m=t%10;printf("%d%,d%,d%,%d",k,h,f,m);printf("%d%,d%,d%,%d",m,f,h,k);}elseif(i/100!=0){printf("3位数");h=i/100;t=i%