vic4key

In tam giác số

Dec 21st, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. /* MinGW build EXE
  4. G++ TamGiacSo.cpp -o TamGiacSo.exe && TamGiacSo.exe
  5. */
  6.  
  7. using namespace std;
  8.  
  9. int main(int, const char * [])
  10. {
  11.     int N = 0;
  12.  
  13.     cout << "Enter a number (0-9): "; cin >> N;
  14.  
  15.     for(int i = 1; i <= N; i++) {
  16.         cout << '\n';
  17.         for(int j = 1; j <= N - i; j++) cout << '\x20';
  18.         for(int k = 1; k <= i; k++) cout << k;
  19.         for(int l = i - 1; l >= 1; l--) cout << l;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment