printStar

#include<iostream>
using namespace std;

/*
    *
   * *
  * * *
 * * * *
* * * * *
* * * * *
 * * * *
  * * *
   * *
    *
*/


void starup(int n) {

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < n - i; j++)
            cout << " ";
        for (int j = 0; j < i; j++)
            cout << "*" << " ";
            
        printf("\n");
    }
}
void stardown(int n) {
    for (int i = 1; i <= n; i++)
    {
        
        for (int j = 1; j< i; j++)
            cout << " ";
        for (int j = 0; j < n - i + 1; j++)
            cout << "* ";
        cout << "\n";
    }
}
int main() {

    starup(5);
    stardown(5);
    return 0;
}

posted @ 2022-07-05 16:25  江南王小帅  阅读(92)  评论(0)    收藏  举报