Advertisement
Myknakryu

Algorytm5 C++ interrupt

Sep 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 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.  
  41.         if(!(i<4))
  42.         {
  43.             cout << "Wybijam z pętli!" <<endl;
  44.             break;
  45.         }
  46.  
  47.         //suma:=suma+a
  48.         cout << suma << " + " << a;
  49.         suma = suma + a;
  50.         cout << " = " << suma  <<endl;
  51.         //a:=a+x
  52.         cout << a << " + " << x;
  53.         a = a + x;
  54.         cout << " = " << a << endl << endl;
  55.     }
  56.     //Wyświetla boolowską reprezentację i < 4
  57.     cout << i << " < 4: ";
  58.     if(i < 4)
  59.     {
  60.         cout << "TAK";
  61.     }
  62.  
  63.     else
  64.     {
  65.         cout << "NIE";
  66.     }
  67.  
  68.     cout << endl << suma;
  69.  
  70.     return 0;
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement