Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     char c;
  8.     int n;
  9.    
  10.     cin >> c >> n;
  11.    
  12.     int sum = 0;
  13.    
  14.     for (int i = n; i < 2 * n; i++) {
  15.         sum += i;
  16.     }
  17.    
  18.     int x = n - 1, y = 1;
  19.    
  20.     cout << sum << endl;
  21.     for (int i = 0; i < n; i++) {
  22.         for (int j = 0; j < x; j++) {
  23.             cout << ' ';
  24.         }
  25.        
  26.         for (int j = 0; j < y; j++) {
  27.             cout << c;
  28.         }
  29.        
  30.         cout << endl;
  31.        
  32.         x--;
  33.         y += 2;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement