解题思路:
注意事项:
参考代码:
#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 人评分