当前位置:网站首页>Niuke real problem programming - day20
Niuke real problem programming - day20
2022-07-07 14:53:00 【weixin_ forty-five million seven hundred and fifty thousand fou】
Compile environment :c++
1、 Print the numeric matrix clockwise
describe :
Given a numerical matrix , Please design an algorithm to print matrix elements clockwise from the upper left corner
Input description :
The first line of input is two numbers , Each represents the number of rows M And number of columns N; Next is M That's ok , Each row N A digital , Represent all the elements of this matrix ; When read M=-1,N=-1 when , Input termination .
Algorithmic thought :
According to the title requirements , To output the digital matrix clockwise . First, store the two-dimensional array , Traverse the two-dimensional array in sequence , From left to right , From top right to bottom right , From bottom right to bottom left , Four small cycles from bottom left to top left . You need to calculate the number of such cycles , Obviously depends on m,n The small one , Find that the number of cycles corresponding to a large cycle is min(m,n)+1 Of 1/2, Integer division will automatically round off the remainder , Just meet the number of times to traverse . Then analyze four small cycles , Pay attention to the boundary between cycles . Output requirements “,” separate , There is no “,”, So you can connect the output to characters , Or with “,”+ Print out in the form of elements . Note that the title has multiple sets of input samples .
The code part implements :
2、 Sentence reversal
describe :
Give a sentence ( Only letters and spaces ), Reverse the word position in the sentence , The words are separated by spaces , There is only one space between the words , There are no spaces around . such as : (1) “hello xiao mi”-> “mi xiao hello”
Algorithmic thought :
Declaration string , Accept the input string in behavioral units . Traversal string , Encountered space count , Record the number of words . Connect each word into a string array . Output all the words in reverse order .
The code part implements :
3、 Hexadecimal conversion
describe :
Given a decimal number M, And the base number to be converted N. Will decimal number M Turn into N Hexadecimal number
Input description :
Enter as one line ,M(32 An integer )、N(2 ≤ N ≤ 16), Space off .
Output description :
Output the converted number for each test instance , One line per output . If N Greater than 9, The corresponding number rules refer to 16 Base number ( such as ,10 use A Express , wait )
Algorithmic thought :
For the input i Decimal system nt, The remainder of each step can be obtained by mathematical rolling division , The output in reverse order is the corresponding number after hexadecimal conversion . When m When it's negative , You need to take a module before you can divide . Because it's bigger than 9 Need to use abcd, The remainder of each division can be used as an index , Include in 0-F Get the corresponding numeric characters from the string of , Connect to the result string . Because you want to output in reverse order , So add one to the last negative number ’-‘ Number , Then print out the result in reverse order .
The code part implements :
边栏推荐
- Ffmpeg --- image processing
- 寺岗电子称修改IP简易步骤
- ES日志报错赏析-maximum shards open
- PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
- 解析PHP跳出循环的方法以及continue、break、exit的区别介绍
- 比尔·盖茨晒48年前简历:“没你们的好看”
- 一文读懂数仓中的pg_stat
- Mlgo: Google AI releases industrial compiler optimized machine learning framework
- Niuke real problem programming - day13
- 因员工将密码设为“123456”,AMD 被盗 450Gb 数据?
猜你喜欢
leetcode:648. 单词替换【字典树板子 + 寻找若干前缀中的最短符合前缀】
AWS学习笔记(三)
Instructions d'utilisation de la trousse de développement du module d'acquisition d'accord du testeur mictr01
KITTI数据集简介与使用
8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
How to enable radius two factor / two factor (2fa) identity authentication for Anheng fortress machine
广州开发区让地理标志产品助力乡村振兴
Huawei cloud database DDS products are deeply enabled
JSON解析实例(Qt含源码)
Computer win7 system desktop icon is too large, how to turn it down
随机推荐
[today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
EfficientNet模型的完整细节
How to enable radius two factor / two factor (2fa) identity authentication for Anheng fortress machine
Classification of regression tests
CTFshow,信息搜集:web9
C 6.0 language specification approved
Half an hour of hands-on practice of "live broadcast Lianmai construction", college students' resume of technical posts plus points get!
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
leetcode:648. Word replacement [dictionary tree board + find the shortest matching prefix among several prefixes]
Emqx 5.0 release: open source Internet of things message server with single cluster supporting 100million mqtt connections
Apache多个组件漏洞公开(CVE-2022-32533/CVE-2022-33980/CVE-2021-37839)
Cocoscreator resource encryption and decryption
数据湖(九):Iceberg特点详述和数据类型
Niuke real problem programming - Day9
buffer overflow protection
关于后台动态模板添加内容的总结 Builder使用
「2022年7月」WuKong编辑器更版记录
全球首款 RISC-V 笔记本电脑开启预售,专为元宇宙而生!
JS in the browser Base64, URL, blob mutual conversion
Niuke real problem programming - day16