标签:style blog http io ar color os sp for
1 #include <cstdio> 2 #include <cstring> 3 4 char s[10]; 5 6 int main(int argc, char** argv) 7 { 8 int n; 9 scanf("%d", &n); 10 for(int i = 10000; i <= 999999; i++) 11 { 12 sprintf(s, "%d", i); 13 int len = strlen(s); 14 bool ok = true; 15 for(int k = 0; k < 3; k++) 16 if(s[k] != s[len - k - 1]) 17 ok = false; 18 if(ok) 19 { 20 int sum = 0; 21 for(int j = 0; j < len; j++) 22 sum += s[j]-‘0‘; //将字符型数字转化为数字型 ,‘0’的ASCLL是48 23 if(sum == n) 24 printf("%s\n", s); 25 } 26 } 27 return 0; 28 }
标签:style blog http io ar color os sp for
原文地址:http://www.cnblogs.com/justzyx/p/4139836.html