Advertisement
pan7nikt

zad_2_1

Oct 9th, 2023
893
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n = 0;
  9.     cout << "Podaj liczbe calkowita: ";
  10.     cin >> n;
  11.  
  12.     //Od 1 do n
  13.     for(int i=1;i<=n;i++)
  14.         {
  15.             cout << i << " ";
  16.         }
  17.  
  18.     //Od n do 1
  19.     cout << "\n";
  20.     for(int i=n;i>=1;i--)
  21.         {
  22.             cout << i << " ";
  23.         }
  24.  
  25.     //nieparzyste <n
  26.     cout << "\n";
  27.     for(int i=n;i>=1;i--)
  28.         {
  29.             if(i%2 != 0)
  30.                 {
  31.                     cout << i << " ";
  32.                 }
  33.         }
  34.  
  35.     //parzyste <n
  36.     cout << "\n";
  37.     for(int i=n;i>=1;i--)
  38.         {
  39.             if(i%2 == 0 && i%3 == 2)
  40.                 {
  41.                     cout << i << " ";
  42.                 }
  43.         }
  44.  
  45.     //wielokrotnosci 5
  46.     cout << "\n";
  47.     for(int i=n;i>=1;i--)
  48.         {
  49.             if(i%5 == 0)
  50.                 {
  51.                     cout << i << " ";
  52.                 }
  53.         }
  54.  
  55.     //od A do Z
  56.     cout << "\n";
  57.     for(int i='a';i<='z';i++)
  58.         {
  59.             cout << (char)i << " ";
  60.         }
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement