当前位置:网站首页>电子协会 C语言 1级 28 、字符菱形
电子协会 C语言 1级 28 、字符菱形
2022-06-25 04:05:00 【dllglvzhenfeng】
电子协会 C语言 1级 28 、字符菱形
C语言代码:
/*
电子协会 C语言 1级 28 、字符菱形
http://noi.openjudge.cn/ch0101/09/
给定一个字符,用它构造一个对角线长 5 个字符,倾斜放置的菱形。
输入:输入只有一行, 包含一个字符。
输出
该字符构成的菱形。
样例输入
*
样例输出
*
***
*****
***
*
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch;
//给定一个字符,
scanf("%c",&ch);
//用它构造一个对角线长5个字符,倾斜放置的菱形。
printf(" %c\n",ch);
printf(" %c%c%c\n",ch,ch,ch);
printf("%c%c%c%c%c\n",ch,ch,ch,ch,ch);
printf(" %c%c%c\n",ch,ch,ch);
printf(" %c\n",ch);
return 0;
}C++代码:
/*
电子协会 C语言 1级 28 、字符菱形
http://noi.openjudge.cn/ch0101/09/
给定一个字符,用它构造一个对角线长 5 个字符,倾斜放置的菱形。
输入:输入只有一行, 包含一个字符。
输出
该字符构成的菱形。
样例输入
*
样例输出
*
***
*****
***
*
*/
#include<iostream> //使用cin,cout,须调用iostream库
using namespace std;
int main()
{
char a; //定义字符变量,
cin>>a; //输入给定一个字符
cout<<" "<<a<<endl; //输出1个字符,先输出2个空格
cout<<" "<<a<<a<<a<<endl; //输出3个字符,先输出1个空格
cout<<a<<a<<a<<a<<a<<endl; //输出5个字符
cout<<" "<<a<<a<<a<<endl; //输出3个字符,先输出1个空格
cout<<" "<<a<<endl; //输出1个字符,先输出2个空格
return 0; //结束程序
}python3代码:
a = input()
print(' '+a+' ')
print(' '+a+a+a+' ')
print(a+a+a+a+a)
print(' '+a+a+a+' ')
print(' '+a+' ')边栏推荐
- 小白一键重装官网下载使用方法
- buuctf(re)
- 【图像融合】基于matlab方向离散余弦变换和主成分分析图像融合【含Matlab源码 1907期】
- ORA-00800: soft external error
- Ranorex Studio 10.1 Crack
- [relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear
- 两小时带你进入软件测试行业风口(附全套软件测试学习路线)
- Opensea PHP development kit
- Database low-end SQL query statement fragment
- DMA double buffer mode of stm32
猜你喜欢

SOC验证环境的启动方式

How micro engine uploads remote attachments

How to download and use Xiaobai one click reload on the official website

buuctf web

buuctf(re)

My IC journey - the growth of senior chip design verification engineers - "Hu" said that IC engineers are perfect and advanced

leetcode1221. Split balance string

XSS (cross site script attack) summary (II)

How to install the blue lake plug-in to support Photoshop CC 2017

以太网是什么要怎么连接电脑
随机推荐
PHP calls map API
At the age of 30, I began to learn programming by myself. Is it still time for me to have difficulties at home?
Records of ros2/dds/qos/ topics
Matlab notes
How to use the Magic pig system reinstallation master
buuctf(re)
【图像融合】基于matlab方向离散余弦变换和主成分分析图像融合【含Matlab源码 1907期】
【FLink】access closed classloader classloader. check-leaked-classloader
Database overview
Eyeshot 2022 Released
Native JS high risk reminder pop-up code snippet, "are you sure you want to do this?" and "it cannot be recovered after deletion. Do you want to continue“
Use js to simply implement the apply, call and bind methods
What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect
Summary of SQL injection (I)
Customize the console plot result style
Method of opening data recovery of solid state disk
基于Cortex-M3、M4的精准延时(系统定时器SysTick延时,可用于STM32、ADuCM4050等)
Web3 DAPP user experience best practices
OOP vector addition and subtraction (friend + copy construction)
ORA-00800: soft external error