[C.C++] NOI题库答案(1.1-09 字符菱形)

3116 1
guxinlei 2022-12-22 15:31:24 | 显示全部楼层 |阅读模式
网址:http://noi.openjudge.cn

描述
给定一个字符,用它构造一个对角线长5个字符,倾斜放置的菱形。

输入
输入只有一行, 包含一个字符。

输出
该字符构成的菱形。

样例输入
  1. *
复制代码


样例输出
  1.   *
  2. ***
  3. *****
  4. ***
  5.   *
复制代码


答案
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.         char n;
  6.         cin>>n;
  7.         cout<<"  "<<n<<endl;
  8.         cout<<" "<<n<<n<<n<<endl;
  9.         cout<<n<<n<<n<<n<<n<<endl;
  10.         cout<<" "<<n<<n<<n<<endl;
  11.         cout<<"  "<<n<<endl;
  12.         return 0;
  13. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

guxinlei

荣誉红客

关注
  • 24
    主题
  • 0
    粉丝
  • 1
    关注
青,取之于蓝而胜于蓝;冰,水为之而寒于水。

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2025 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行