当前位置:网站首页>Draw squares with Obama (Lua)
Draw squares with Obama (Lua)
2022-07-07 19:04:00 【Just be interesting】
subject
President Barack Obama is not only calling on everyone to learn to program , Even code by example , Became the first president in American history to write computer code .2014 end of the year , To celebrate “ Computer science education week ” The official launch of , Obama wrote very simple computer code : Draw a square on the screen . Now you can draw with him !
Input format :
Enter the length of the side of the square in one line N(3≤N≤21) And some kind of character that forms the side of a square C, Space between .
Output format :
Output by given character C Square drawn . But notice that the row spacing is larger than the column spacing , So to make the result look more like a square , The number of rows we output is actually the number of columns 50%( Round to the nearest whole ).
sample input :
10 a
sample output :
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
Code
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
边栏推荐
- Golang client server login
- 【Unity Shader】插入Pass实现模型遮挡X光透视效果
- Redis cluster and expansion
- What is the general yield of financial products in 2022?
- 50亿,福建又诞生一只母基金
- 10 schemes to ensure interface data security
- How to choose the appropriate automated testing tools?
- 2022年推荐免费在线接收短信平台(国内、国外)
- Charles+Postern的APP抓包
- AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
猜你喜欢
Reinforcement learning - learning notes 8 | Q-learning
Creative changes brought about by the yuan universe
将模型的记忆保存下来!Meta&UC Berkeley提出MeMViT,建模时间支持比现有模型长30倍,计算量仅增加4.5%...
A few simple steps to teach you how to see the K-line diagram
低代码助力企业数字化转型会让程序员失业?
Save the memory of the model! Meta & UC Berkeley proposed memvit. The modeling time support is 30 times longer than the existing model, and the calculation amount is only increased by 4.5%
How to choose the appropriate automated testing tools?
[software test] from the direct employment of the boss of the enterprise version, looking at the resume, there is a reason why you are not covered
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
嵌入式C语言程序调试和宏使用的技巧
随机推荐
[information security laws and regulations] review
Wireshark analyzes packet capture data * cap
线程池和单例模式以及文件操作
Kubernetes DevOps CD工具对比选型
Skills of embedded C language program debugging and macro use
RISCV64
App capture of charles+postern
Industry case | digital operation base helps the transformation of life insurance industry
NAT地址转换
Will domestic software testing be biased
idea彻底卸载安装及配置笔记
Tips for short-term operation of spot silver that cannot be ignored
PTA 1102 教超冠军卷
GSAP animation library
Recommend free online SMS receiving platform in 2022 (domestic and foreign)
How to choose the appropriate automated testing tools?
企业展厅设计中常用的三种多媒体技术形式
Save the memory of the model! Meta & UC Berkeley proposed memvit. The modeling time support is 30 times longer than the existing model, and the calculation amount is only increased by 4.5%
Usage of PHP interview questions foreach ($arr as $value) and foreach ($arr as $value)
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的