Advertisement
Myknakryu

Algorytm5 C++

Sep 18th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int i, a, x, suma;
  8.  
  9.     i = 0;
  10.     a = 2;
  11.     x = 4;
  12.     suma = 0;
  13.  
  14.     // Wypisuje startowe wartości
  15.     cout << "i = " << i << endl;
  16.     cout << "a = " << a << endl;
  17.     cout << "x = " << x << endl;
  18.     cout << "suma = " << suma << endl;
  19.  
  20.     cout << endl;
  21.  
  22.     for(;i < 4;)
  23.     {
  24.         cout << i << " < 4: ";
  25.  
  26.         //Wyświetla boolowską reprezentację i < 4
  27.         if(i < 4)
  28.         {
  29.             cout << "TAK" << endl;
  30.         }
  31.  
  32.         else
  33.         {
  34.             cout << "NIE" << endl;
  35.         }
  36.         //i:=i+1
  37.         cout << i << " + 1 =";
  38.         i++;
  39.         cout << i  <<endl;
  40.         //suma:=suma+a
  41.         cout << suma << " + " << a;
  42.         suma = suma + a;
  43.         cout << " = " << suma  <<endl;
  44.         //a:=a+x
  45.         cout << a << " + " << x;
  46.         a = a + x;
  47.         cout << " = " << a << endl << endl;
  48.     }
  49.     //Wyświetla boolowską reprezentację i < 4
  50.     cout << i << " < 4: ";
  51.     if(i < 4)
  52.     {
  53.         cout << "TAK";
  54.     }
  55.  
  56.     else
  57.     {
  58.         cout << "NIE";
  59.     }
  60.  
  61.     cout << endl << suma;
  62.  
  63.     return 0;
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement