本题要求编写程序读入5个字符串按由小到大的顺序输出。输入格式:输入为由空格分隔的5个非空字符串每个字符串不包括空格、制表符、换行符等空白字符长度小于80。输出格式:按照以下格式输出排序后的结果:After sorted每行一个字符串
#include
int main() { string s[5]; for (int i = 0; i < 5; i++) { cin >> s[i]; } sort(s, s + 5); //排序 cout << "After sorted:" << endl; for (int i = 0; i < 5; i++) { cout << s[i] << endl; } return 0; }
原文地址: https://www.cveoy.top/t/topic/bfnm 著作权归作者所有。请勿转载和采集!