ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
>[info]给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。 ~~~C #include <stdio.h> int main() { long w,q,b,s,g,x; printf("input five num:\n"); scanf("%ld",&x); w = x/10000; q = x%10000/1000; b = x%1000/100; s = x%100/10; g = x%10; if(w!=0) printf("为5位数,逆序为:%ld %ld %ld %ld %ld\n", g,s,b,q,w); else if(q!=0) printf("为4位数,逆序为:%ld %ld %ld %ld\n", g,s,b,q); else if(b!=0) printf("为3位数,逆序为:%ld %ld %ld\n", g,s,b); else if(s!=0) printf("为2位数,逆序为:%ld %ld\n", g,s); else if(g!=0) printf("为1位数,逆序为:%ld\n", g); return 0; } ~~~