c语言如何将分解出来的数字重新按逆序组合出新的数学
1个回答
关注
展开全部
有两种写法。第一种:#include#includeint main() { int a,b,c,num,ans; printf("Input num:"); scanf("%d",&num); a=fabs(num/100); b=fabs((num/10)%10); c=fabs(num%10); ans=c*100+b*10+a; printf("a=%d,b=%d,c=%d,ans=%d\n",a,b,c,ans); return 0;}第二种:#includeint main() { int a,b,c,num; printf("Input number:\n"); scanf("%d",&num); while(num<0) { num=num*-1; } a=num%10; b=num%100/10; c=num/100; printf("reversal number is %d\n",a*100+b*10+c); return 0;}
咨询记录 · 回答于2022-10-26
c语言如何将分解出来的数字重新按逆序组合出新的数学
有两种写法。第一种:#include#includeint main() { int a,b,c,num,ans; printf("Input num:"); scanf("%d",&num); a=fabs(num/100); b=fabs((num/10)%10); c=fabs(num%10); ans=c*100+b*10+a; printf("a=%d,b=%d,c=%d,ans=%d\n",a,b,c,ans); return 0;}第二种:#includeint main() { int a,b,c,num; printf("Input number:\n"); scanf("%d",&num); while(num<0) { num=num*-1; } a=num%10; b=num%100/10; c=num/100; printf("reversal number is %d\n",a*100+b*10+c); return 0;}
麻烦师傅帮忙看看这题
main(){int a,b=0,t;scanf("%d",&a);t=a;while(t>0){b=b*10+t%10;t/=10;}printf("a=%d\nb=%d\n",a,b);printf("a+b=%d\n",a+b);}main(){int a,b=0,t;scanf("%d",&a);t=a;while(t>0){b=b*10+t%10;t/=10;}printf("a=%d\nb=%d\n",a,b);printf("a+b=%d\n",a+b);}
已赞过
评论
收起
你对这个回答的评价是?