Let me ask first, have your final exam results come out? Anyway, our class has come out [crying]. . .
Eat "Fried Meat with Bamboo Shoots" tonight, not to mention how sour it is. . .
Let’s talk about the results first (not Versailles!!!): Grade 6, Chinese 97, Mathematics 99, English 97, the third in the class, the first in the single Chinese class, the grade is unknown
Do you think it's good, but! ! ! Parents don't think so. . .
Alright, let's not talk about being sad, let's get back to the topic
topic description
Input three strings and output them in ascending order
enter
3 lines of string
output
Output in 3 lines from small to large
sample input
cde
afg
abc
sample output
abc
afg
cde
Is it very simple, I think so, but I need to talk about getline in C++ first
What is the header file of getline? ? ?
The getline function is the same as the header file required by the string, and the getline function needs to be called in the header file #include<string>
Introduction to getline
getline is a C++ standard library function; it has two forms, one is the input stream member function in the header file <istream>; the other is an ordinary function in the header file <string>;
It encounters the following situations that will cause the generated string to end:
(1) to the end of the file, (2) the delimiter of the function is encountered, (3) the input reaches the maximum
for example:
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
string s;
cout<<"输入字符串:";
getline(cin,s);
cout<<"输出字符串:";
cout<<s;
return 0;
}
Finally, let's talk about its prototype
The getline function prototype getline(std::cin, string s, char ch), indicates that the character ch is used to end the reading of the string
It is enough for getline to understand these, let’s look at the AC code next .
#include <bits/stdc++.h>
using namespace std;
int main()
{
string x,y,z;
getline(cin,x);
getline(cin,y);
getline(cin,z);
if(x>y&&x>z)
if(y>z)
cout<<z<<endl<<y<<endl<<x;
if(x>y&&x>z)
if(z>y)
cout<<y<<endl<<z<<endl<<x;
if(y>x&&y>z)
if(x>z)
cout<<z<<endl<<x<<endl<<y;
if(y>x&&y>z)
if(z>x)
cout<<x<<endl<<z<<endl<<y;
if(z>x&&z>y)
if(x>y)
cout<<y<<endl<<x<<endl<<z;
if(z>x&&z>y)
if(y>x)
cout<<x<<endl<<y<<endl<<z;
}