-
Notifications
You must be signed in to change notification settings - Fork 0
/
prob4.cc
51 lines (45 loc) · 1.17 KB
/
prob4.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <cmath>
using namespace std;
int blah(int foo);
int main()
{
long tmpprod;
long maxpalim=1;
int digits=1, digits_half=1;
for(int i=100; i<1000; i++)
{
for(int j=100; j<1000; j++)
{
tmpprod=i*j;
digits=log10(tmpprod);
digits_half=digits/2;
// cout << "DEBUG: " << "tmpprod" << tmpprod << "digits " << digits << "digits_half " << digits_half << endl;
if(digits%2==0)
{
if((tmpprod/blah(digits_half+1))%10 == (tmpprod/blah(digits_half-1))%10 &&
tmpprod/blah(digits_half+2)%10 == tmpprod/blah(digits_half-2)%10)
{
cout << tmpprod << "ist ein Palindrom" << endl;
if(tmpprod > maxpalim) maxpalim=tmpprod;
}
}
if(digits%2!=0)
{
if(tmpprod/blah(digits_half+1)%10 == tmpprod/blah(digits_half-0)%10 &&
tmpprod/blah(digits_half+2)%10 == tmpprod/blah(digits_half-1)%10 &&
tmpprod/blah(digits_half+3)%10 == tmpprod/blah(digits_half-2)%10 )
{
cout << tmpprod << " ist ein Palindrom" << endl;
if(tmpprod > maxpalim) maxpalim=tmpprod;
}
}
}
}
cout << endl << endl << endl ;
cout << "Maximum Palim " << maxpalim;
}
int blah(int foo)
{
return pow(10,foo);
}