编写一个能对字符串数组由小到大进行排序的小程序。
测试输入:
banana
apple
orange
grape
blueberry
预期输出:
apple
banana
blueberry
grape
orange
请补全如下代码:
#include<iostream>
#include<string>
using namespace std;
//设计一个程序实现对一个字符串数组由小到大排序
//在此处完成对该排序函数的定义
//--------------------------------
//主函数验证
int main()
{
//用户输入五个字符串
string s[5];
int i;
for(i = 0; i < 5; i++)
{
cin >> s[i];
}
//此处,调用排序函数进行字母序由小到大排序
stringsort(s, 5);
//---------------------------
//显示正确的排序结果
for(i = 0; i < 5; i++)
{
cout << s[i] << endl;
}
return 0;
}