Facebook
From Fiery Marmoset, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 826
  1. #include <iostream>
  2. using namespace std;
  3. int x, ile;
  4. char wybor;
  5. int main()
  6. {
  7.     cout << "Podaj x ";
  8.     cin>>x;
  9.     cout<<"Jakie liczby wyswietlic - p czy n? "<<endl;
  10.     cin>>wybor;
  11.     switch(wybor)
  12.     {
  13.         case 'p':
  14.         case 'P':
  15.         {
  16.             for(int i=1; i<=x; i++)
  17.             {
  18.                 if(i%2==0)
  19.                 {
  20.                     cout<<i<<" ";
  21.                     ile++;
  22.                 }
  23.             }
  24.             cout<<endl;
  25.             cout<<"Wyswietlono "<<ile<<" liczb";
  26.             break;
  27.         }
  28.         case 'n':
  29.         {
  30.             for(int i=1; i<=x; i++)
  31.             {
  32.                 if(i%2!=0)
  33.                 {
  34.                     cout<<i<<" ";
  35.                     ile++;
  36.                 }
  37.             }
  38.             cout<<endl;
  39.             cout<<"Wyswietlono "<<ile<<" liczb";
  40.             break;
  41.         }
  42.     }
  43.     return 0;
  44. }
  45.