7-1 find the smallest string the subject requires a program to output the smallest string for the input n strings.
Input format:
Enter the first line to give a positive integer n, followed by n lines, each row gives a non-empty string of less than 80 length, where no newline, space, tab characters appear.
Output format:
Output the smallest string in one line in the following format:
Min is: Minimum string input Sample:
5 Li Wang Zha Jin Xian Output Sample:
Min Is:jin
Answer:
1#include <iostream>2#include <string>3 using namespacestd;4 5 intMain ()6 { 7 intN;8 stringMin, K;9 TenCin>>N; OneCin>>K; Amin=K; - - for(intI=0; i<n-1; i++) the { - -Cin>>K; - + if(k<min) min=K; - + } Acout<<"Min is:"<<Min<<Endl; at //System ("pause"); -}
Attach the commissioning process:
1#include <iostream>2#include <string>3 using namespacestd;4 5 intMain ()6 {7 intN;8 stringMax,min, K;9 TenCin>>N; One Acout<<"Please enter"<<N<<"A string:"<<Endl; - -Cin>>K; theMax =K; -min=K; - -cout <<"K:"<<k<<Endl; +cout <<"Max:"<<Max<<Endl; -cout <<"Min:"<<Min<<Endl; + A for(intI=1; i<n;i++) at { -cout<<"Please enter section"<<i+1<<"A string:"<<Endl; -Cin>>K; - - if(K>max) max=K; -cout <<"Max:"<<Max<<Endl; in if(k<min) min=K; -cout <<"Min:"<<Min<<Endl; to + } -cout<<"Max is:"<<Max<<Endl; thecout<<"Min is:"<<Min<<Endl; * $System"Pause"); Panax Notoginseng -}
Perhaps you have a better idea, welcome to communicate!
[Pta]7-1 Find the smallest string for the input n string, output the smallest string (c + +)