编程实现从键盘输入5个国名(每个国名最长80个字符),找出并输出按字典顺序排在最前面的国名 求改错c++#include #include using namespace std;int main(){char string[80];char str[5][80];int i;cout
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/20 11:59:47
![编程实现从键盘输入5个国名(每个国名最长80个字符),找出并输出按字典顺序排在最前面的国名 求改错c++#include #include using namespace std;int main(){char string[80];char str[5][80];int i;cout](/uploads/image/z/12479546-2-6.jpg?t=%E7%BC%96%E7%A8%8B%E5%AE%9E%E7%8E%B0%E4%BB%8E%E9%94%AE%E7%9B%98%E8%BE%93%E5%85%A55%E4%B8%AA%E5%9B%BD%E5%90%8D%EF%BC%88%E6%AF%8F%E4%B8%AA%E5%9B%BD%E5%90%8D%E6%9C%80%E9%95%BF80%E4%B8%AA%E5%AD%97%E7%AC%A6%EF%BC%89%2C%E6%89%BE%E5%87%BA%E5%B9%B6%E8%BE%93%E5%87%BA%E6%8C%89%E5%AD%97%E5%85%B8%E9%A1%BA%E5%BA%8F%E6%8E%92%E5%9C%A8%E6%9C%80%E5%89%8D%E9%9D%A2%E7%9A%84%E5%9B%BD%E5%90%8D+%E6%B1%82%E6%94%B9%E9%94%99c%2B%2B%23include+%23include+using+namespace+std%3Bint+main%28%29%7Bchar+string%5B80%5D%3Bchar+str%5B5%5D%5B80%5D%3Bint+i%3Bcout)
编程实现从键盘输入5个国名(每个国名最长80个字符),找出并输出按字典顺序排在最前面的国名 求改错c++#include #include using namespace std;int main(){char string[80];char str[5][80];int i;cout
编程实现从键盘输入5个国名(每个国名最长80个字符),找出并输出按字典顺序排在最前面的国名 求改错c++
#include
#include
using namespace std;
int main()
{char string[80];
char str[5][80];
int i;
cout
编程实现从键盘输入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