Skip to content

Instantly share code, notes, and snippets.

@nwg-piotr
Created August 4, 2020 12:46
Show Gist options
  • Save nwg-piotr/b74c418ef50821d97fea5f2f056fafc9 to your computer and use it in GitHub Desktop.
Save nwg-piotr/b74c418ef50821d97fea5f2f056fafc9 to your computer and use it in GitHub Desktop.
Pudges exercise in C++
#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