Created
August 4, 2020 12:46
-
-
Save nwg-piotr/b74c418ef50821d97fea5f2f056fafc9 to your computer and use it in GitHub Desktop.
Pudges exercise in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
int main(int argc, char *argv[]) { | |
for (int i=1000; i<10000; i++) { | |
std::string s = std::to_string(i); | |
int sum = std::stoi(s.substr(0, 2)) + std::stoi(s.substr(2, 2)); | |
if (sum * sum == i) { | |
std::cout << i << "\n"; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment