Guest User

Untitled

a guest
Dec 16th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int f(int k){
  4. int l=1;
  5. while((l+1)*(l+1)<k){
  6. l=l+1;
  7. }
  8. return l;
  9. }
  10. int main()
  11. {
  12. int i,j,m,b,a,c;
  13. c=0;
  14. bool v=false;
  15. setlocale(LC_ALL,"Russian");
  16. cin>>m;
  17. for(i=0;i<=f(m);i++){
  18. a=i*i;
  19. for(j=0;j<=f(m);j++){
  20. b=j*j;
  21. if (m==(a+b)){
  22. c=c+1;
  23. v=true;
  24. if (c==1)
  25. cout<<"Да, можно!"<<endl;
  26. cout<<"Первое число="<<i<<" Второе число="<<j<<endl;
  27. }
  28. }
  29. }
  30. if (v==false)
  31. cout<<"Нет, нельзя!"<<endl;
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment