Advertisement
Welcius

P72484: Rombe

Jan 22nd, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int size;
  6.     cin >> size;
  7.     for(int i = 1; i <= size; ++i) {
  8.         int espais, asteriscs;
  9.         espais = asteriscs = 0;
  10.         //Here be dragons
  11.         while (espais < size - i){
  12.             cout << " ";
  13.             ++espais;
  14.         }
  15.         while (asteriscs < 2 * i - 1) {
  16.             cout << "*";
  17.             ++asteriscs;
  18.         }
  19.         cout << endl;
  20.         // Cal fer la part inversa del rombe
  21.     }
  22.     for(int j = size - 1; j >= 1; --j) {
  23.         int espais, asteriscs;
  24.         espais = asteriscs = 0;
  25.         //Here be dragons
  26.         while (espais < size - j){
  27.             cout << " ";
  28.             ++espais;
  29.         }
  30.         while (asteriscs < 2 * j - 1) {
  31.             cout << "*";
  32.             ++asteriscs;
  33.         }
  34.         cout << endl;
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement