CPP
cpp
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
#include <iostream>
#include <math.h>
using namespace std;
int n;
bool valid(int s){
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++){
if (s==(i*i+j*j)){
cout<<i<<"^2+"<<j<<"^2=";
return true;}}}
return false;
}
void check_function (){
cout<<"Enter the natural number n = "; // Введите натуральное число.
cin>>n;
cout<<endl<<"Numbers having a full squares: \n"; // Числа имеющие сумму квардратов двух натуральных чисел.
for (int s=1;s<=n;s++){
if(valid(s)==true){
cout<<s<<"\n";}}
}
int main(){
check_function ();
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run