当前位置:网站首页>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
边栏推荐
- go语言的字符串类型、常量类型和容器类型
- POJ 2392 Space Elevator
- Reuse of data validation framework Apache bval
- Will low code help enterprises' digital transformation make programmers unemployed?
- POJ 1182 :食物链(并查集)[通俗易懂]
- Kirk borne's selection of learning resources this week [click the title to download directly]
- 二叉树的基本概念和性质
- Idea completely uninstalls installation and configuration notes
- C语言中匿名的最高境界
- 6.关于jwt
猜你喜欢

伺服力矩控制模式下的力矩目标值(fTorque)计算

低代码助力企业数字化转型会让程序员失业?

Tips for short-term operation of spot silver that cannot be ignored

CVPR 2022 - learning non target knowledge for semantic segmentation of small samples

小试牛刀之NunJucks模板引擎

线程池和单例模式以及文件操作

持续测试(CT)实战经验分享
![[Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question](/img/08/5f4b4e2700606554516807c01454fd.png)
[Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question
![学习open62541 --- [67] 添加自定义Enum并显示名字](/img/98/e5e25af90b3f98c2be11d7d21e5ea6.png)
学习open62541 --- [67] 添加自定义Enum并显示名字

嵌入式C语言程序调试和宏使用的技巧
随机推荐
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
PTA 1102 教超冠军卷
单臂路由和三层交换的简单配置
What is the general yield of financial products in 2022?
Multimodal point cloud fusion and visual location based on image and laser
A few simple steps to teach you how to see the K-line diagram
Tsinghua, Cambridge and UIC jointly launched the first Chinese fact verification data set: evidence-based, covering many fields such as medical society
[Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question
链式二叉树的基本操作(C语言实现)
Idea completely uninstalls installation and configuration notes
虚拟数字人里的生意经
Differences between rip and OSPF and configuration commands
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
线程池的拒绝策略
高温火烧浑不怕,钟薛高想留清白在人间
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
Learn open62541 -- [67] add custom enum and display name
Interview vipshop internship testing post, Tiktok internship testing post [true submission]
Charles+drony的APP抓包
线程池和单例模式以及文件操作