Advertisement
Guest User

zad 8

a guest
Oct 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, x=0;
  8.     cout << "Podaj liczbe:";
  9.     cin >> n;
  10.     while (n!=0)
  11.     {
  12.     if (n%2==0)
  13.     {
  14.         int y=sqrt(n); // pierwiastek licze z podanego "n"
  15.         if (y%2==0) x++; // jesli podziele ten pierwiastek przez 2 to ma nie byc reszty, bo to ma byc kwadrat, wiec nie moze reszty dac
  16.     }
  17.     cout << "Podaj liczbe:";
  18.     cin >> n;
  19.     }
  20.     cout << "Kwadratow liczb parzystych bylo: " << x;
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement