And according to the order from long to short output string, */
# include
# include
using namespace std;
Int main ()
{
Char STR [6] [45].
Char c [45];
Int I, j, x, Max.
for(i=0; I<6; I++)
Cin> STR [I];
Cout
{
Max=I;
For (j=I; J<6; J++)
If (strlen (STR) [j] & gt; Strlen (STR) [I])
Max=j;
Strcpy (c, STR (Max));
Strcpy (STR (Max), STR [I]);
Strcpy (STR [I], c);
}
Cout
Cout
}
CodePudding user response:
There is a problem, way of thinking of writing is not quite rightCodePudding user response:
There is something wrong with the didn't see the shrimps, screenshots,CodePudding user response:
Int main (){
Char STR [6] [45].
Char c [45];
Int I, j, Max.
for(i=0; I<6; I++)
Cin> STR [I];
Cout
{
Max=I;
For (j=I; J<6; J++)
{
If (strlen (STR) [j] & gt; Strlen (STR) [I])
{
Max=j;
Strcpy (c, STR (Max));
Strcpy (STR (Max), STR [I]);
Strcpy (STR [I], c);
}
}
}
Cout
Cout
return 0;
}
So to write to
CodePudding user response:
Should look for the longest string, and c is size, rather than the STR [I]
# include
# include
using namespace std;
Int main ()
{
Char STR [6] [45].
Char c [45];
Int I, j, x, Max.
For (I=0; I & lt; 6; I++)
cin> STR [I];
coutFor (I=0; I & lt; 5; I++)
{
Max=I;
Strcpy (c, STR (Max));
For (j=I + 1; J & lt; 6; J++)
{
If (strlen (STR) [j] & gt; Strlen (c))
{
Max=j;
Strcpy (c, STR (Max));
}
}
If (I.=Max) {
Strcpy (STR (Max), STR [I]);
Strcpy (STR [I], c);
}
}
coutFor (I=0; I & lt; 6; I++)
coutreturn 0;
}