当前位置:网站首页>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 :
边栏推荐
- asp.netNBA信息管理系统VS开发sqlserver数据库web结构c#编程计算机网页源码项目详细设计
- JS in the browser Base64, URL, blob mutual conversion
- Small game design framework
- CTFshow,信息搜集:web14
- FFmpeg----图片处理
- Several ways of JS jump link
- PyTorch模型训练实战技巧,突破速度瓶颈
- Cvpr2022 | backdoor attack based on frequency injection in medical image analysis
- 2022云顾问技术系列之高可用专场分享会
- Lidar Knowledge Drop
猜你喜欢
13 ux/ui/ue best creative inspiration websites in 2022
拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条...
用于增强压缩视频质量的可变形卷积密集网络
C# 6.0 语言规范获批
Pandora IOT development board learning (HAL Library) - Experiment 12 RTC real-time clock experiment (learning notes)
Ian Goodfellow, the inventor of Gan, officially joined deepmind as research scientist
Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
Substance painter notes: settings for multi display and multi-resolution displays
Substance Painter筆記:多顯示器且多分辨率顯示器時的設置
In the field of software engineering, we have been doing scientific research for ten years!
随机推荐
缓冲区溢出保护
半小时『直播连麦搭建』动手实战,大学生技术岗位简历加分项get!
15、文本编辑工具VIM使用
Apache multiple component vulnerability disclosure (cve-2022-32533/cve-2022-33980/cve-2021-37839)
AWS learning notes (III)
What is cloud primordial? This time, I can finally understand!
数据库如何进行动态自定义排序?
Cvpr2022 | backdoor attack based on frequency injection in medical image analysis
electron remote 报错
Five pain points for big companies to open source
Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
Deformable convolutional dense network for enhancing compressed video quality
Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched
潘多拉 IOT 开发板学习(HAL 库)—— 实验12 RTC实时时钟实验(学习笔记)
Applet directory structure
Concurrency Control & NoSQL and new database
防火墙基础之服务器区的防护策略
#yyds干货盘点# 解决名企真题:交叉线
Data Lake (IX): Iceberg features and data types
Apache多个组件漏洞公开(CVE-2022-32533/CVE-2022-33980/CVE-2021-37839)