麻烦大家帮我写一下c++程序输出下列图形

来源:学生作业学帮网 编辑:学帮网 时间:2024/07/02 02:52:07

麻烦大家帮我写一下c++程序输出下列图形

#include <iostream>
using namespace std;

void prtStar(int offset){
\x09for(int i=0;i < offset;++i)
\x09\x09cout<<" ";
\x09cout<<"* "<<endl;
\x09for(int i=0;i < offset;++i)
\x09\x09cout<<" ";
\x09cout<<"* * "<<endl;
\x09for(int i=0;i < offset;++i)
\x09\x09cout<<" ";
\x09cout<<"  * "<<endl;
}

int main(){
\x09prtStar(0);\x09
\x09cout<<"* * * * "<<endl;
\x09prtStar(4);
\x09cout<<"* * * * * * * * "<<endl;
\x09prtStar(8);\x09
\x09cout<<"        * * * * "<<endl;
\x09prtStar(12);

return 0;
}

 执行结果: