Codeup ContestID:100000577 问题 A: 输出梯形

题目链接http://codeup.cn/problem.php?cid=100000577&pid=0

题目描述
输入一个高度h,输出一个高为h,上底边为h的梯形。

输入
一个整数h(1<=h<=1000)。

输出
h所对应的梯形。

样例输入
5

样例输出

        *****
      *******
    *********
  ***********
*************

代码

#include<stdio.h>
	int main() {
		int h;
		scanf("%d", &h);
		for(int i = 0; i < h; i++) {
			for(int j = 3 * h - 2; j >=0; j -= 2 ){
				if(j > 2 * h - 2 - 2 * i)
					printf("*");
				else
					printf(" ");
			}
			printf("\n");
		}
		return 0;
	}

[注]:OJ未通过, 答案错误50, 有大佬知道原因, 还请赐教, 多谢!

发布了75 篇原创文章 · 获赞 1 · 访问量 2054

猜你喜欢

转载自blog.csdn.net/Rhao999/article/details/103947746