当前位置:网站首页>电子协会 C语言 1级 7 、画矩形
电子协会 C语言 1级 7 、画矩形
2022-06-10 22:04:00 【dllglvzhenfeng】
电子协会 C语言 1级 7 、画矩形
http://noi.openjudge.cn/ch0105/42/
C++代码:
/*
电子协会 C语言 1级 7 、画矩形
http://noi.openjudge.cn/ch0105/42/
根据参数,画出矩形。
输入:
输入一行,包括四个参数:前两个参数为整数,依次代表矩形的高和宽(高不少于 3 行
不多于 10 行,宽不少于 5 列不多于 10 列);第三个参数是一个字符,表示用来画图的
矩形符号;第四个参数为 1 或 0,0 代表空心,1 代表实心。
输出:输出画出的图形。
样例输入
7 7 @ 0
样例输出
@ @ @ @ @ @ @
@ @
@ @
@ @
@ @
@ @
@ @ @ @ @ @ @
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int l,w;
char s;
int flag;
cin>>l>>w>>s>>flag;
if(flag==1){
for(int i=1;i<=l;i++){
for(int j=1;j<=w;j++){
cout<<s;
}
cout<<endl;
}
}
else
{
for(int i=1;i<=w;i++)
{
cout<<s;
}
cout<<endl;
for(int i=2;i<=l-1;i++){
for(int j=1;j<=w;j++){
if(j==1 || j==w)
{
cout<<s;
}
else
{
cout<<" ";
}
}
cout<<endl;
}
for(int i=1;i<=w;i++)
{
cout<<s;
}
cout<<endl;
}
return 0;
}python3代码:
"""
1.5编程基础之循环控制 42 画矩形
http://noi.openjudge.cn/ch0105/42/
"""
h,w,st,k= input().split(' ')
h = int(h)
w = int(w)
k = int(k)
if k == 0:
for i in range(0,h):
if i==0 or i==h-1:
for j in range(w):
print(st,end='')
print('\n',end='')
else:
for j in range(w):
if j == 0 or j== w-1:
print(st,end='')
else:
print(' ',end='')
print('\n',end='')
elif k==1:
for i in range(0,h):
for j in range(0,w):
print(st,end='')
print('\n',end='')
边栏推荐
- 2022g1 industrial boiler stoker test questions and online simulation test
- [original] analysis of nine price HPV data capture of Yilu app
- Static routing configuration of serial interface in router experiment (Supplement)
- Laravel8 enables alicloud file upload
- js敏感信息泄露检测工具
- 06 15 10 20 神秘代码,等你破译
- How Photoshop opens, edits and exports pictures in webp format
- Fallback operation in SVN
- 数据与信息资源共享平台(九)
- 关于String.format(String format, Object... args)
猜你喜欢

2022 t elevator repair test question simulation test question bank and online simulation test

软件测试入门之软件测试的概念与过程(精辟内容)

Multus CNI deployment and basic use of kubernetes multi network card scheme
![Authoritative guide to Web3 technology stack [2022]](/img/76/0f64604f5e5355300f5ec498ea23e1.png)
Authoritative guide to Web3 technology stack [2022]

数组、List、Set、Map、Properties依赖注入格式

【GMM+KDE】基于MATLAB的GMM和KDE核估计得目标跟踪仿真

Vulnhub practice DC-1 target

vulnhub之dc4

Fallback operation in SVN

Keras深度学习实战(8)——使用数据增强提高神经网络性能
随机推荐
Déploiement et utilisation de base de la carte multi - réseau kubernets
玩电子,穷三代
Keras deep learning practice (8) -- using data enhancement to improve neural network performance
数据与信息资源共享平台(八)
kubernetes 二进制安装(v1.20.15)(六)部署WorkNode节点
MySQL MVCC 多版本并发控制
Template_ Calculate number of combinations
Blue Bridge Cup_ A fool sends a letter_ recursion
Image mosaic camera mosaic notes
Can Huawei matepad become the secondary screen of your laptop?
但身示你五县非那最土zaiFKMW
06 15 10 20 神秘代码,等你破译
Custom view: graphics and image processing (I): using simple pictures
关于高考的那些事儿
MySQL组合索引不被命中使用的情况
28岁自学编程会不会太晚了?靠谱吗?
Simulated 100 questions and simulated examination of G2 utility boiler stoker examination in 2022
UE4骨骼动画新手入门
[content co creation] issue 17: summer is hot and you are so sweet! Participating in the signing of Huawei cloud Xiaobian, there is always a pattern gift bag that moves you!
Face recognition software based on deepface model