Kacper_Michalak

Zadanie pętle 15

Dec 13th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x = 15, y = 0;
  7.     int i;
  8.     int z = x;
  9.     int a = 0;
  10.  
  11.     for (i = 0; i < x; i++)
  12.     {
  13.         y = y + z;
  14.         z--;
  15.     }
  16.     a = 2 * y;
  17.     cout << "Ilosc cegiel w piramidzie wynosi: " << y << endl;
  18.     cout << "Laczna waga wynosi: " << a <<" kg"<< endl;
  19.    
  20. }
Advertisement
Add Comment
Please, Sign In to add comment