Advertisement
pan7nikt

zad_1_4

Oct 9th, 2023 (edited)
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int rok = 0;
  9.     bool correct = 0;
  10.    
  11.     while(!correct)
  12.     {
  13.         cout << "Podaj rok: ";
  14.         cin >> rok;
  15.    
  16.         if(rok <= 0){
  17.         cout<<"Podany rok nie moze byc liczba ujemna \n";
  18.         correct = false;
  19.         }
  20.         else{
  21.         correct = true;}
  22.     };
  23.  
  24.    
  25.    
  26.     if((fmod((float)rok,4) == 0) && (fmod((float)rok,100) != 0) && (fmod((float)rok,400) == 0))
  27.     {
  28.         cout << "Ten rok jest przestepny!";
  29.     }
  30.     else
  31.     {
  32.         cout << "Ten rok nie jest przestepny!";
  33.     }
  34.     return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement