例题2.4输出梯形

#include <iostream>
#include <cstdio>
using namespace std;
int h;
int main() {
 //  while(cin>>h)防止仍有数据未输入完,防止死循环超时 
    while(scanf(&quot;%d&quot;,&amp;h)!=EOF)
    {
    int col;
    col=h+2*(h-1);
    int kong=0;
    int xing=0;

    for(int i=1;i<=h;i++)
    {
    xing=h+(i-1)*2;
    kong=col-xing;
    for(int j=1;j<=kong;j++)
    {
    cout<<&quot; &quot;;
}
    for(int k=1;k<=xing;k++)
    {
    cout<<&quot;*&quot;;
}
cout<<endl;

}
}

}
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-25 17:13
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务