输入5个字符串(长度小于10),比较大小,将最大串和最小串连接,大串在前,小串在后
你的提问有问题,哈哈哈哈哈。要信息全面。不要这样没头没尾的。直接要代码的帖子,还免费的,很少的人愿意回复你。
char str[5][11] = { 0 }, newstr[22] = { 0 }, maxstr[11] = { 0 }, minstr[11] = {0};
for (int i = 0; i < 5; i++)
{
scanf_s("%s", str[i],_countof(str[i]));
}
strcpy_s(minstr, str[0]);
strcpy_s(maxstr, str[0]);
for (int i = 0; i < 5; i++)
{
if (strcmp(str[i], maxstr)>0)
{
strcpy_s(maxstr, str[i]);
}
else if (strcmp(str[i], minstr) < 0)
{
strcpy_s(minstr, str[i]);
}
}
strcat_s(newstr, sizeof(newstr), maxstr);
strcat_s(newstr, sizeof(newstr), minstr);
printf("%s", newstr);