ProjectEuler 004题

 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main() {
 5     bool isPalindromic (int num);
 6     int res = 0;
 7 
 8     for(int i = 100; i < 1000 ; i++)
 9         for(int j = 100; j < 1000; j++) {
10             if( isPalindromic(i*j) && i*j > res)
11                 res = i*j;
12         }
13     cout << res;
14     system("pause");
15     return 0;
16 }
17 //判断回文
18 bool isPalindromic(int num) {
19     int rev_num = 0;
20     int m = num;//
21     while(m != 0) {
22         rev_num = rev_num * 10 + m%10;
23         m = m/10;
24     }
25     if( rev_num == num)
26         return true;
27     else
28         return false;
29 }

 

posted @ 2014-05-24 09:08  soul390  阅读(125)  评论(0编辑  收藏  举报