Created
March 12, 2016 13:27
-
-
Save rkt2spc/698f9d3d8820a075ac06 to your computer and use it in GitHub Desktop.
Print out n-layered number-triangle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <math.h> | |
using namespace std; | |
int main() | |
{ | |
int n = 15; | |
for (int i = 1; i <= n; i++) | |
{ | |
for (int t = 0; t < (n - i); t++) | |
cout << " "; | |
for (int j = 1; j < i * 2; j++) | |
{ | |
cout << (2 * i - 1 - abs(j - i)) % 10 << " "; | |
} | |
cout << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment