当前位置:网站首页>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
边栏推荐
- Idea completely uninstalls installation and configuration notes
- Do you really understand sticky bag and half bag? 3 minutes to understand it
- The live broadcast reservation channel is open! Unlock the secret of fast launching of audio and video applications
- What is the general yield of financial products in 2022?
- Redis publishing and subscription
- Five network IO models
- POJ 2392 Space Elevator
- RISCV64
- 2022-07-04 matlab读取视频帧并保存
- 嵌入式C语言程序调试和宏使用的技巧
猜你喜欢
Static routing configuration
[论文分享] Where’s Crypto?
CVPR 2022丨学习用于小样本语义分割的非目标知识
如何选择合适的自动化测试工具?
The performance and efficiency of the model that can do three segmentation tasks at the same time is better than maskformer! Meta & UIUC proposes a general segmentation model with better performance t
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
Creative changes brought about by the yuan universe
A few simple steps to teach you how to see the K-line diagram
[information security laws and regulations] review
App capture of charles+postern
随机推荐
10 schemes to ensure interface data security
持续测试(CT)实战经验分享
Redis cluster and expansion
App capture of charles+drony
Charles+drony的APP抓包
2022-07-04 matlab读取视频帧并保存
AntiSamy:防 XSS 攻击的一种解决方案使用教程
Skills of embedded C language program debugging and macro use
Calculation of torque target value (ftorque) in servo torque control mode
将模型的记忆保存下来!Meta&UC Berkeley提出MeMViT,建模时间支持比现有模型长30倍,计算量仅增加4.5%...
App capture of charles+postern
Will domestic software testing be biased
Three forms of multimedia technology commonly used in enterprise exhibition hall design
coming! Gaussdb (for Cassandra) new features appear
[information security laws and regulations] review
What is the general yield of financial products in 2022?
Cadre de validation des données Apache bval réutilisé
Thread factory in thread pool
2022上半年朋友圈都在传的10本书,找到了
线程池的拒绝策略