Skip to content

Instantly share code, notes, and snippets.

@rkt2spc
Created March 12, 2016 13:27
Show Gist options
  • Save rkt2spc/698f9d3d8820a075ac06 to your computer and use it in GitHub Desktop.
Save rkt2spc/698f9d3d8820a075ac06 to your computer and use it in GitHub Desktop.
Print out n-layered number-triangle
#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