当前位置:网站首页>电子协会 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='')
边栏推荐
- Operation of simulated examination platform for welder (primary) test questions in 2022
- MA8601 pin√pin替代汤铭FE1.1s无须更改电路板|完美替代FE1.1s方案
- Auto.js pro 开发环境配置
- js敏感信息泄露检测工具
- 200个C语言单词,请收藏!
- Laravel8 enables alicloud file upload
- 线程池的创建
- Vulnhub practice DC-1 target
- The definition of the metauniverse and the seven infinite features
- Multus CNI deployment and basic use of kubernetes multi network card scheme
猜你喜欢

关于idea中src下 无法new一个package

Bottom layer communication protocol ① of single chip microcomputer -- synchronous and asynchronous, parallel and serial, full duplex and half duplex, simplex, level signal and differential signal

Thread pool: a magic weapon for managing threads

Question bank and simulation test of 2022 tea artist (intermediate) operation certificate examination

Interpreting the registry class of mmcv

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

数据与信息资源共享平台(四)

Sherri Monroe was appointed as the new executive director of the additive manufacturers green trade association

IP反查域名

IP anti query domain name
随机推荐
中银证券开户有什么风险吗?安全的吗?
Flex layout syntax
Distributed Foundation
UE4 getting started with bone animation
Déploiement et utilisation de base de la carte multi - réseau kubernets
【QPSK中频】基于FPGA的QPSK中频信号产生模块verilog设计
Is it safe to open a BOC securities account? Is the risk high?
Vscode common shortcuts
我们对产业互联网的认识,还是困囿于互联网式的平台和中心的逻辑之中
项目实训13——界面补充
优化代码去除if-else
Vulnhub practice DC-1 target
2022 Shanghai safety officer C certificate operation certificate examination question bank simulated examination platform operation
PKI/TLS瑞士军刀之cfssl
Multus CNI deployment and basic use of kubernetes multi network card scheme
06151020 mysterious code, waiting for you to decipher
[006] initial string
Reading notes on the way of Huawei data
DC4 of vulnhub
SMB anonymous