#include<iostream> #include<cmath> #include<string> #include<sstream> using namespace std; bool isZhenshu(float a) { int b = a; if (a == b)return true; else return false; } int main() { int bg, end; string a; getline(cin, a); for (int i = 0; i < a.size(); i++) { if (a[i] == ',') { bg = stoi(a.substr(0,i)); end = stoi(a.substr(i + 1, a.size() - i)); } } float temp; for (int i = bg; i <=end; i++) { for (int j = i; j <=end; j++) { temp = sqrt(i * i + j * j); if (temp <=end && isZhenshu(temp)) { cout << i << "^2+" << j << "^2+=" << (int)temp << "^2"<<endl; } } } } |
Double click to view unformatted code.