Advertisement
Kacper_Michalak

Zadanie pętle 2

Dec 1st, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i;
  7.     int x, y;
  8.     int tymczasowa;
  9.  
  10.     cout << "Podaj pierwszy kraniec przedzialu" << endl;
  11.     cin >> x;
  12.     cout << "Podaj drugi kraniec przedzialu" << endl;
  13.     cin >> y;
  14.  
  15.     if (y < x)
  16.     {
  17.         tymczasowa = y;
  18.         y = x;
  19.         x = tymczasowa;
  20.     }
  21.     cout << "\n";
  22.     for (i = x; i <= y; i++)
  23.     {
  24.         if (i % 3 == 0)
  25.         {
  26.             cout << i << " liczba jest podzielna przez 3" << endl;
  27.         }
  28.         else
  29.         {
  30.             cout << i << " liczba nie podzielna przez 3" << endl;
  31.         }
  32.     }
  33.    
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement