-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem4.cpp
More file actions
executable file
·61 lines (45 loc) · 793 Bytes
/
Problem4.cpp
File metadata and controls
executable file
·61 lines (45 loc) · 793 Bytes
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
52
53
54
55
56
57
58
59
60
/*
* Problem4.cpp
*
* Created on: Nov 18, 2014
* Author: explicitname
*/
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
int isPal(int prod)
{
string stringConv;
ostringstream convert;
convert << prod;
stringConv = convert.str();
if (stringConv == string(stringConv.rbegin(), stringConv.rend())) {
return 1;
} else {
return 0;
}
}
int main()
{
int prod = 10;
int highPal;
for (int i = 999; i >= 100; i--) {
for (int j = 999; j >= 100; j--)
{
prod = (j * i);
cout << prod << endl;
cout << i << " x " << j << "\n" << endl;
if (isPal(prod) == 1)
{
if (prod > highPal)
{
highPal = prod;
}
}
}
}
cout << highPal << " is the highest Palindrome!" << endl;
return 0;
}