ユーザーはいくつかの文字列を入力し、完了したら文字列としてスペースを入力する必要があります。コードは、入力された最長および最短の単語を返す必要があります。
strcmp は常に -1 を返します...何が間違っていますか?
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char S[100][20];
int I = 0;
do {
cout << "Enter text:" << endl;
cin.getline(S[I],100);
} while (I < 19 && strcmp(S[I++],""));
char Max[100], Min[100];
strcpy(Max, S[0]);
strcpy(Min, S[0]);
for (int J = 1; J < I; J++) {
if (strcmp(S[J], Max) == 1)
strcpy(Max, S[J]);
if (strcmp(S[J], Min) == -1)
strcpy(Min, S[J]);
}
cout << "Max = " << Max << endl;
cout << "Min = " << Min << endl;
system("pause");
return 0;
}