如何用c语言完成以下题目

img

#include <stdio.h>
int main()
{
    int i,j;
    for(i = 1;i<=9;i++)
    {
        if(i<=5)
        {
            for(j=0;j<i;j++)
                printf("* ");

        }else
        {
            for(j=0;j<9-i;j++)
                printf("* ");
        }
        
        printf("\n");
    }
    return 0;
}

#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
using namespace std;
int main(){
    int i=1;
    while(i!=10){
        int j=1;
        if(i<=5){
            while(j<=i){
                cout<<"* ";
                j++;
            }    
        }else{
            while(j<=10-i){
                j++;
                cout<<"* ";
            }
        }
        cout<<endl;
        i++;
    }
}