Advertisement
Cygan

Laborka2

Dec 18th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void for_nieparzyste(int a, int b)
  6. {
  7.     cout << "(FOR) Liczby nieparzyste to: ";
  8.     for(a; a < b; a++ )
  9.     {
  10.         if (a%2!=0)
  11.             cout<< a<<", ";
  12.     }
  13. }
  14.  
  15. int while_nieparzyste(int a, int b)
  16. {
  17.     cout << "(WHILE) Liczby nieparzyste to: ";
  18.     while (a<b)
  19.     {
  20.         if(a%2!=0)
  21.             cout<< a<<", ";
  22.         a++;
  23.     }
  24. }
  25. int dowhile_nieparzyste(int a, int b)
  26. {
  27.     cout << "(DO WHILE) Liczby nieparzyste to: ";
  28.     do
  29.     {
  30.         if(a%2!=0)
  31.             cout<< a<<", ";
  32.         a++;
  33.     } while (a<b);
  34. }
  35.  
  36. int main()
  37. {
  38.     cout << "Wprowadz liczby A i B zatwierdzajac je klawiszem RETURN" << endl;
  39.     int a=0, b=0;
  40.     cin >> a >> b;
  41.     for_nieparzyste(a,b);
  42.     cout<<endl;
  43.     while_nieparzyste(a,b);
  44.     cout<<endl;
  45.     dowhile_nieparzyste(a,b);
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement