forked from github/dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (32 loc) · 710 Bytes
/
main.cpp
File metadata and controls
40 lines (32 loc) · 710 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
/*
ID: unityjo1
TASK: palsquare
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
void reverse(string& str)
{
int n = str.length();
for (int i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]);
}
bool isPalindrome(int a){
string pal = to_string(a);
reverse(pal);
if(pal == to_string(a)) return true;
return false;
}
int B;
int main() {
ofstream fout ("palsquare.out");
ifstream fin ("palsquare.in");
fin >> B;
for(int i=1; i<=300; i++){
if(int(reverse(to_string(i))[0])==B){}
if(isPalindrome(i*i)){ fout << i << " " << i*i << "\n";}
}
return 0;
}