标签:\n include cst 基础 顺序 描述 调用 ring sub
基础练习 回文数
1 while (temp) 2 { 3 A[j ++] = temp % 10; 4 temp /= 10; 5 }
C/C++代码实现(AC):
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <cmath> 6 #include <stack> 7 #include <map> 8 #include <queue> 9 10 using namespace std; 11 12 inline void solve() 13 { 14 int temp1[6]; 15 for (int i = 1000; i <= 9999; ++ i) 16 { 17 int j = 0, temp = i; 18 while(temp) 19 { 20 temp1[j ++] = temp % 10; 21 temp /= 10; 22 } 23 bool flag = true; 24 for (int k = 0; k <= j / 2; ++ k) 25 { 26 if (temp1[k] != temp1[j - 1 - k]) 27 { 28 flag = false; 29 break; 30 } 31 } 32 if (flag) printf("%d\n", i); 33 } 34 return ; 35 } 36 37 int main() 38 { 39 // 调用solve(),判断是否满足条件
40 solve(); 41 return 0; 42 }
标签:\n include cst 基础 顺序 描述 调用 ring sub
原文地址:https://www.cnblogs.com/GetcharZp/p/9034130.html