当前位置:网站首页>跟奥巴马一起画方块(Lua)
跟奥巴马一起画方块(Lua)
2022-07-07 15:38:00 【有趣就行】
题目
美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写计算机代码的总统。2014年底,为庆祝“计算机科学教育周”正式启动,奥巴马编写了很简单的计算机代码:在屏幕上画一个正方形。现在你也跟他一起画吧!
输入格式:
输入在一行中给出正方形边长N(3≤N≤21)和组成正方形边的某种字符C,间隔一个空格。
输出格式:
输出由给定字符C画出的正方形。但是注意到行间距比列间距大,所以为了让结果看上去更像正方形,我们输出的行数实际上是列数的50%(四舍五入取整)。
输入样例:
10 a
输出样例:
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
代码
local s = io.read()
local n, ch
for i = 1, #s do
if s:sub(i,i) == " " then
n, ch = s:sub(1, i - 1), s:sub(i+1)
break
end
end
ch = ch:rep(n)
for i = 1, n / 2 + 0.5 do
print(ch)
end
边栏推荐
- QT中自定义控件的创建到封装到工具栏过程(一):自定义控件的创建
- [Seaborn] implementation of combined charts and multi subgraphs
- 【Seaborn】组合图表、多子图的实现
- centos7安装mysql笔记
- Rpcms method of obtaining articles under the specified classification
- LeetCode 535(C#)
- [Seaborn] combination chart: pairplot and jointplot
- MySQL usage notes 1
- LeetCode 1186. Delete once to get the sub array maximum and daily question
- 让保险更“保险”!麒麟信安一云多芯云桌面中标中国人寿, 助力金融保险信息技术创新发展
猜你喜欢

How to add aplayer music player in blog

鲲鹏开发者峰会2022 | 麒麟信安携手鲲鹏共筑计算产业新生态

QML beginner

浅浅理解.net core的路由

Nerf: the ultimate replacement for deepfake?

A tour of grpc:03 - proto serialization / deserialization

What is cloud computing?

Is AI more fair than people in the distribution of wealth? Research on multiplayer game from deepmind
![[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial](/img/14/4e7ebfb1ed5b99f8377af9d17d2177.jpg)
[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial

Lex & yacc of Pisa proxy SQL parsing
随机推荐
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
Solidity 开发环境搭建
Linux 安装mysql8.X超详细图文教程
LeetCode 1654. 到家的最少跳跃次数 每日一题
无法链接远程redis服务器(解决办法百分百)
QML beginner
Seaborn data visualization
From Devops to mlops: how do it tools evolve to AI tools?
LeetCode 1986. The minimum working time to complete the task is one question per day
mysql实现两个字段合并成一个字段查询
第二十四届中国科协湖南组委会调研课题组一行莅临麒麟信安调研考察
LeetCode 1155. 掷骰子的N种方法 每日一题
PLC:自动纠正数据集噪声,来洗洗数据集吧 | ICLR 2021 Spotlight
Sator launched Web3 game "satorspace" and launched hoobi
测试用例管理工具推荐
Sator推出Web3游戏“Satorspace” ,并上线Huobi
How to add aplayer music player in blog
如何在软件研发阶段落地安全实践
L1-023 输出GPLT(Lua)
SlashData开发者工具榜首等你而定!!!