哈理工 2139 魔幻菱形

魔幻菱形
Time Limit: 1000 MSMemory Limit: 32768 K
Total Submit: 246(172 users)Total Accepted: 179(165 users)Rating: Special Judge: No
Description

图案输出总会让人不屑一顾,但是谁也不能保证在最短的时间内AC。

Input

多组数据测试。

每组数据有一个整数n,表示菱形高度。(n >= 3&& n为奇数)

Output

 输出高度为n的横向挨着的2个菱形。

Sample Input

7

Sample Output

   *      *

  ***    ***

 *****  *****

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

 *****  *****

  ***    ***

   *      *

Source

2014暑假集训练习赛(7月30日)

 

 

打印菱形挺简单的 ,找关系就好了

#include<iostream>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=0;i<=n/2;i++)
        {
            for(int x=0;x<n/2-i;x++)
                cout<<" ";

            for(int j=n/2-i;j<=n/2+i;j++)
                cout<<"*";
                for(int y=n/2+i+1;y<n+n/2-i;y++)
                    cout<<" ";
            for(int k=n+n/2-i;k<=n/2+n+i;k++)
                cout<<"*";
            cout<<endl;
        }
        for(int m=1;m<=n/2;m++)//        {
           {
               for(int l=0;l<m;l++)
               cout<<" ";
               for(int t=m;t<n-m;t++)
               cout<<"*";
               for(int d=n-m+1;d<=n+m;d++)
                cout<<" ";
               for(int e=n+m;e<2*n-m;e++)
                cout<<"*";
               cout<<endl;

           }
      }

    return 0;
}


 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值