当前位置:网站首页>Basic exercises of test questions letter graphics ※
Basic exercises of test questions letter graphics ※
2022-06-13 02:07:00 【Jerry-hao】
Error model :
n,m = map(int,input().split())
c = ['A']*m
for i in range(n):
c[i] = 'A'
for j in range(i+1,m):
c[j]=chr(ord(c[j-1])+1)
if i>=1:
for k in range(i-1,-1,-1):
c[k]=chr(ord(c[k+1])+1)
#print(c,end='')
for l in range(m):
print(c[l],end='')
print()Cause of error : Found per line A After the position of , Start generating letters backwards , Then forward to produce letters .
Take a chestnut ,hack data :26 2
When the number of rows is greater than the number of columns ,A Will disappear , Then I can't find A The array is out of bounds ( stay k Where? ).
Correct solution , Only describe the relationship ( abs(i-j) ), Don't map to position .
n,m = map(int,input().split())
for i in range(n):
for j in range(m):
print( chr(ord('A')+abs(i-j)),end='' )
print()
come from :
边栏推荐
- cin,cin. get(),cin. Summary of the use of getline() and getline()
- Application and examples of C language structure
- Calculation of accuracy, recall rate, F1 value and accuracy rate of pytorch prediction results (simple implementation)
- 如何解决通过new Date()获取时间写出数据库与当前时间相差8小时问题【亲测有效】
- 16 embedded C language interview questions (Classic)
- Logging system in chromium
- The method of drawing rounded panel with Delphi
- Vscode configuration header file -- Take opencv and its own header file as an example
- synchronized下的 i+=2 和 i++ i++执行结果居然不一样
- [unity] problems encountered in packaging webgl project and their solutions
猜你喜欢

10 days based on stm32f401ret6 smart lock project practice day 1 (environment construction and new construction)

DFS and BFS to solve Treasure Island exploration

Opencv camera calibration (1): internal and external parameters, distortion coefficient calibration and 3D point to 2D image projection

回顾ITIL各版本历程,找到企业运维发展的关键点

Huawei equipment configures private IP routing FRR

In the third quarter, the revenue and net profit increased "against the trend". What did vatti do right?

How to learn C language and share super detailed experience (learning note 1 -- basic data types of C language)

Sensor: MQ-5 gas module measures the gas value (code attached at the bottom)

Uniapp preview function

Huawei equipment is configured with CE dual attribution
随机推荐
华为设备配置CE双归属
How to learn C language and share super detailed experience (learning note 1 -- basic data types of C language)
rsync 傳輸排除目錄
反爬虫策略(ip代理、设置随机休眠时间、哔哩哔哩视频信息爬取、真实URL的获取、特殊字符的处理、时间戳的处理、多线程处理)
微服务开发环境搭建
Alertwindowmanager pop up prompt window help (Part 1)
SQL server deletes all tables and all stored procedures in the database
uniapp 预览功能
Introduction to Google unit testing tools GTEST and gmoke
[learning notes] xr872 audio driver framework analysis
Establishment of microservice development environment
synchronized下的 i+=2 和 i++ i++执行结果居然不一样
Leetcode daily question - 890 Find and replace mode
[the second day of actual combat of smart lock project based on stm32f401ret6 in 10 days] GPIO and register
Padavan mounts SMB sharing and compiles ffmpeg
Delphi7 compressed pictures (BMP, JPG, PNG)
[work with notes] NDK compiles the open source library ffmpeg
C语言压缩字符串保存到二进制文件,从二进制文件读取压缩字符串后解压。
华为设备配置私网IP路由FRR
移动IPv6光猫登录的一般ip地址账号与密码,移动光猫变桥接模式