Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdio>
- using namespace std;
- int main() {
- int x, n;
- char sign = '*';
- cin >> x; // I'm to lazy to make welcoming cout first
- for (int i = 0; i < x + 1; i++) {
- n = i; //sets n to i before every j loop
- for (int j = 0; j < 2 * i + 1; j++) { //every loop is a star in a row, in first row we need 1 star, in second 3 etc
- if (j > 0) {n = x + 1;} //there's some trickery, after 1st loop it sets n so the "Width number" was 0
- printf("%*c", x + 1 - n, sign); //At fisrt loop it does total heigh + 1 - number of row 'spaces'
- }
- cout << endl;
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement