当前位置:网站首页>电子协会 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='')
边栏推荐
- IP反查域名
- Distributed Foundation
- Missing heritability
- 云数据中心中的SDN/NFV应用
- SMB anonymous
- kubernetes 二进制安装(v1.20.15)(六)部署WorkNode节点
- Is it safe to open a BOC securities account? Is the risk high?
- Blue Bridge Cup_ A fool sends a letter_ recursion
- Watlow签订从施耐德电气手中收购Eurotherm的协议
- [original] analysis of nine price HPV data capture of Yilu app
猜你喜欢

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

That's great. The Ministry of industry and information technology has launched an internet account with a "one click unbinding" mobile phone number, which can be called an artifact

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

Simulated 100 questions and simulated examination of G2 utility boiler stoker examination in 2022

Vulnhub's DC3

Array, list, set, map, properties dependency injection format

Thread pool: a magic weapon for managing threads

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

Native support for the first version of arm64! Microsoft win11/10 free tool set PowerToys 0.59 release

Distributed Foundation
随机推荐
laravel8 实现阿里云文件上传
Laravel8 enables alicloud file upload
MySQL MVCC 多版本并发控制
The definition of the metauniverse and the seven infinite features
IPO can't cure Weima's complications?
数据与信息资源共享平台(五)
原生支持 ARM64 的首个版本!微软 Win11/10 免费工具集 PowerToys 0.59 发布
Thread pool: a magic weapon for managing threads
"Draw the bow as strong, use the arrow as long", Manfu technology opens a new track for the data service industry
kubernetes多網卡方案之Multus CNI部署和基本使用
项目实训10——对特定数据库的备份
2022g1 industrial boiler stoker test questions and online simulation test
但身示你五县非那最土zaiFKMW
Vulnhub practice DC-1 target
DependencyManagement 和 Dependencies
Custom view: graphics and image processing (I): using simple pictures
Interpreting the registry class of mmcv
Object 有哪些常用方法
MA8601 pin√pin替代汤铭FE1.1s无须更改电路板|完美替代FE1.1s方案
Reptiles learn knowledge