解题思路:
注意事项:
参考代码:
#include <iostream> using namespace std; int a[10]; int check(int n) { int t=0; while(n>0) { a[t++]=n%10; //cout<<a[t-1]<<' '; n/=10; } //cout<<endl; int ok=1; for(int i=0;i<t/2;i++) { if(a[i]!=a[t-1-i]) { ok=0; break; } } if(ok) return 1; else return 0; } int main() { int L; cin>>L; int M; while(L--) { cin>>M; int ans=0; while(1) { if(ans>8||check(M)) break; int b=M; int c=0; while(M) { c=c*10+M%10; M/=10; } //cout<<c<<endl; ans++; M=b+c; } //cout<<ans<<endl; if(ans>8) cout<<0<<endl; else cout<<ans<<endl; } //cout << "Hello world!" << endl; return 0; }
0.0分
0 人评分
A+B for Input-Output Practice (VII) (C语言代码)浏览:1381 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:1239 |
大神老白 (C语言代码)浏览:715 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:617 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:541 |
C二级辅导-阶乘数列 (C语言代码)浏览:692 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:476 |
数组与指针的问题浏览:718 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:514 |
生日日数 (C语言代码)浏览:1502 |