作业帮 > 综合 > 作业

编程实现从键盘输入5个国名(每个国名最长80个字符),找出并输出按字典顺序排在最前面的国名 求改错c++

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/13 09:51:13
编程实现从键盘输入5个国名(每个国名最长80个字符),找出并输出按字典顺序排在最前面的国名 求改错c++
#include
#include
using namespace std;
int main()
{char string[80];
char str[5][80];
int i;
cout
/*
Input five countries' names :
china
germen
iran
iraq
french
The minimum is : china
Press any key to continue
*/
#include
#include
using namespace std;

int main() {
char str[5][80];
int i,index = 0; // 假定索引为0排在最前面
cout str[i];
for(i = 1; i < 5; ++i) { // 索引为i和index两两比较
if(strcmp(str[index],str[i]) >= 0) // 如果索引index排在后面
index = i; // 就保存更考前者
}
cout