Created
September 16, 2016 18:11
-
-
Save mgarod/9979dd974ee1a13e1767e26ec4f1642b to your computer and use it in GitHub Desktop.
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> | |
using namespace std; | |
void printTriangle(int n) { | |
for (int i = 0; i < n; ++i) { | |
for (int j = ((2*n-1) - (2*i+1))/2; j > 0; --j){ | |
cout << " "; | |
} | |
for (int k = (2*i+1); k > 0; --k){ | |
cout << "*"; | |
} | |
cout << endl; | |
} | |
} | |
int main() { | |
int n; | |
cin >> n; | |
printTriangle(n); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment