current position：Home>PTA 7-1 string sorting (10 points)
PTA 7-1 string sorting (10 points)
2022-02-02 11:39:55 【CSDN Q & A】
This question requires the preparation of procedures , Read in 5 A string , Output in order of small to large .
Input format ：
Input is space delimited 5 Non empty strings , Each string does not contain spaces 、 tabs 、 Blank characters such as line breaks , The length is less than 80.
Output format ：
Output the sorted results in the following format ：
One string per line
sample input ：
red yellow blue black white
No blank lines at the end
for(i=0;i<5;i++) // What's this for ？
for(i=0;i<4;i++) // Why is there less than four ？
scanf("%s",s[i]); // Why not s[i][j]？
if(strcmp(s[j],s[j+1])>0) this strcmp（） I can't understand why it's written like this ？
for(j=0;j<4-i;j++) //j＜4-i What do you mean ？
strcpy(t,s[j]); strcpy(s[j],s[j+1]); strcpy(s[j+1],t);
for(i=0;i<5;i++) // Why do you want one here for loop , Why? i Less than 5 了 ？
Can someone give me a detailed analysis ？ I can't understand the program , In addition to the questions I raised above , The boss can have other explanations . Please, please, please , Teach me .
author[CSDN Q & A],Please bring the original link to reprint, thank you.
The sidebar is recommended
- How to read text from TXT document, write it into excel and run it in reverse?
- Calculation of joint torque of detal manipulator
- Give a string representing the date and ask what day of the year it is
- [Vue] setting @ media to query font size is not effective
- How to use the ecarts national map to the city? I CV changed other people's codes and key values. Now this is the case
- Design database (agricultural products sales database, clothing sales database and stamen sales database)
- Let's see if the course sequence of distributed architect is correct
- What's the matter with me? Please answer
- Link failure of distributed task scheduling