当前位置:网站首页>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
边栏推荐
- 6.关于jwt
- Thread factory in thread pool
- Hutool - lightweight DB operation solution
- Do you really understand sticky bag and half bag? 3 minutes to understand it
- Three forms of multimedia technology commonly used in enterprise exhibition hall design
- Redis集群与扩展
- Charles+Postern的APP抓包
- CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
- 如何给“不卖笔”的晨光估值?
- [information security laws and regulations] review
猜你喜欢
Charles+drony的APP抓包
如何选择合适的自动化测试工具?
微信网页调试8.0.19换掉X5内核,改用xweb,所以x5调试方式已经不能用了,现在有了解决方案
A few simple steps to teach you how to see the K-line diagram
Learn open62541 -- [67] add custom enum and display name
Comparison and selection of kubernetes Devops CD Tools
String type, constant type and container type of go language
C语言中匿名的最高境界
Redis
数据验证框架 Apache BVal 再使用
随机推荐
testing and SQA_动态白盒測试[通俗易懂]
How to choose the appropriate automated testing tools?
Improve application security through nonce field of play integrity API
来了!GaussDB(for Cassandra)新特性亮相
Five network IO models
Wechat web debugging 8.0.19 replace the X5 kernel with xweb, so the X5 debugging method can no longer be used. Now there is a solution
UVALive – 4621 Cav 贪心 + 分析「建议收藏」
Realize payment function in applet
The highest level of anonymity in C language
POJ 2392 Space Elevator
ip netns 命令(备忘)
Kirk Borne的本周学习资源精选【点击标题直接下载】
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
[paper sharing] where's crypto?
高温火烧浑不怕,钟薛高想留清白在人间
Charles+Postern的APP抓包
Redis cluster and expansion
CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
线程池和单例模式以及文件操作
2022-07-04 matlab reads video frames and saves them