Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a = 0, b = 0, c = 3;
  6.  
  7. void p1(int nr)
  8. {
  9.     if (nr == 0)
  10.     {
  11.         a = 10;
  12.     }
  13.     if (nr == 1)
  14.     {
  15.         a = 10;
  16.         b = b + 5;
  17.     }
  18.     if (nr == 2)
  19.     {
  20.         a = 10;
  21.         b = b + 5;
  22.         c = c + a;
  23.     }
  24. }
  25.  
  26. void p1out(int nr)
  27. {
  28.     if (nr == 0)
  29.     {
  30.         cout<<"a = 10";
  31.     }
  32.     if (nr == 1)
  33.     {
  34.         cout<<"a = 10 | b = b + 5";
  35.     }
  36.     if (nr == 2)
  37.     {
  38.         cout << "a = 10 | b = b + 5 | c = c + a";
  39.     }
  40.     if(nr==3)
  41.         cout << "------------";
  42. }
  43.  
  44. void p2(int nr)
  45. {
  46.     if (nr == 0)
  47.     {
  48.         b = b + c;
  49.     }
  50.     if (nr == 1)
  51.     {
  52.         b = b + c;
  53.         a = a + b;
  54.     }
  55. }
  56.  
  57. void p2out(int nr)
  58. {
  59.     if (nr == 0)
  60.     {
  61.         cout<<"b = b + c";
  62.     }
  63.     if (nr == 1)
  64.     {
  65.         cout<<"b = b + c | a = a + b";
  66.     }
  67.     if(nr==2)
  68.         cout << "------------";
  69. }
  70.  
  71. void p3(int nr)
  72. {
  73.     if (nr == 0)
  74.     {
  75.         c = b + 10;
  76.     }
  77.     if (nr == 1)
  78.     {
  79.         c = b + 10;
  80.         a = 2 * a;
  81.     }
  82.     if (nr == 2)
  83.     {
  84.         c = b + 10;
  85.         a = 2 * a;
  86.         b = b + a;
  87.     }
  88. }
  89.  
  90. void p3out(int nr)
  91. {
  92.     if (nr == 0)
  93.     {
  94.         cout<<"c = b + 10";
  95.     }
  96.     if (nr == 1)
  97.     {
  98.         cout<<"c = b + 10 | a = 2 * a";
  99.     }
  100.     if (nr == 2)
  101.     {
  102.         cout<<"c = b + 10 | a = 2 * a | b = b + a";
  103.     }
  104.     if(nr==3)
  105.         cout << "------------";
  106. }
  107.  
  108. int main()
  109. {
  110.     for (int i = 0;i < 4;i++)
  111.     {
  112.        
  113.         for (int j = 0; j < 3; j++)
  114.         {
  115.            
  116.             for (int k = 0; k < 4; k++)
  117.             {
  118.                
  119.                 p1(i);
  120.                 p2(j);
  121.                 p3(k);
  122.                 p1out(i);
  123.                 cout << endl;
  124.                 p2out(j);
  125.                 cout << endl;
  126.                 p3out(k);
  127.                 cout << endl;
  128.                 cout<< (a + b + c) << endl;
  129.                 a = 0;
  130.                 b = 0;
  131.                 c = 3;
  132.                
  133.             }
  134.         }
  135.     }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement