C++中任意输入一个正整数,将它逆序打印出来.用循环语句做

#define

#include<stdio.h> #include<string.h> char s[10005]; int main() { int ok,i; while(scanf("%s",s) == 1) { i = strlen(s)-1; ok = 0; while(i>-1) { if(ok == 1) printf("%c",s[i]); else if(s[i]-'0'!=0) { ok = 1; printf("%c",s[i]); } i --; } printf("\n"); } return 0; }
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜