Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main(){
  6. int a,b,c,d,valor1,valor2;
  7. double sol;
  8. bool fin = false;
  9. cin >> a >> b>> c>> d;
  10. valor1 = a, valor2 = c;
  11. while(((a<=valor1) && (valor1 <= b)) && (fin == false)){
  12. valor2 = c;
  13. while((c<=valor2) && (valor2<=d) && (fin == false)){
  14. sol = (valor1*valor1)+(valor2*valor2);
  15. if(sqrt(sol)-int(sqrt(sol)) == 0){
  16. fin = true;
  17. }
  18. if(fin == false){
  19. ++valor2;
  20. }
  21. }
  22. if(fin == false){
  23. ++valor1;
  24. }
  25. }
  26. if(fin == false){
  27. cout << "Sense solucio!"<< endl;
  28. }
  29. else{
  30. cout << valor1 << "^2 + " << valor2 << "^2 = " << sqrt(sol) << "^2" << endl;
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement