水题你也过不了3
2014-02-28 14:35
155 查看
21273: 植树都费劲分数: 1
时间限制:1 秒内存限制:128 兆
特殊判题: 否
提交:53
解决: 11
题目描述
山东建筑大学一直以美丽校园著称,这不又快植树节了,校长看了看风水,找了块好地,打算在这块空地上植树,为了使植树都美丽,校长决定把树木排列成菱形。校长说了“现在给你我们所拥有的树木要值成边为N的菱形的形状。”你能帮他吗?(用*代表树木)。
输入格式
多组测试数据。一个整数N(1<=10)
输出
排列成菱形图形的*号。在图案中:每行树木之间无空行,每列树木之间均有一个空列。
样例输入
3
样例输出
** *
* *
* *
*
*** 提示已隐藏,点击上方 [+] 可显示 ***
分类
http://sdjzu.acmclub.com/index.php?app=problem_title&id=147&problem_id=21273#include<stdio.h> main() { int n=0,i=0,j=0; while(scanf("%d",&n)!=EOF) { for(i=1;i<n+1;i++) { for(j=0;j<n-i;j++) { if(j==0) printf(" "); else printf(" "); } if(i==n) printf("*"); else printf(" *"); for(j=1;i-1>0>0&&j<=2*i-3;j++) printf(" "); if(i-1>0) printf(" *"); printf("\n"); } for(i=n-1;i>0;i--) { for(j=0;j<n-i;j++) { if(j==0) printf(" "); else printf(" "); } printf(" *"); for(j=1;i-1>0>0&&j<=2*i-3;j++) printf(" "); if(i-1>0) printf(" *"); printf("\n"); } } }
相关文章推荐
- UVa 11054 - Wine trading in Gergovia(扫描法 水题)
- 洛谷 1414 数论 分解因数 水题
- acm-uva488(水题)
- 古代密码 字符串水题
- HDOJ 题目2089 不要62 (打表 水题)
- Codeforces 492A Vanya and Cubes【水题】
- HDOJ 题目2018母牛的故事(递推 水题)
- CCF 201409-1 相邻数对 (水题)
- How Many Tables 并查集+水题+hdu
- Codeforces Round #379 (Div. 2) A. Anton and Danik(水题)
- hdu 4891---水题 但是WA了很多次
- PAT甲题题解-1102. Invert a Binary Tree (25)-(建树,水题)
- HDU 3215 The first place of 2^n (数论-水题)
- 今天做了一道叫《看电影》的水题
- HDU 4006 The kth great number (基本算法-水题)
- PAT(Advanced Level) 1019 - General Palindromic Number(水题)
- hdu 2571 fate 动态规划水题
- cantor表和笨小猴(水题)
- hdu2043-水题
- codeforces 746 B. Decoding【水题】