#include
#include
Void main ()
{
Char s [100], a [10] [10], [10] b;
Int I, j, k, len, flag.
Gets (s);
Len=strlen (s);
J=0; K=0; flag=0;
for(i=0; i
{
A [k] [j] [I]=s;
j++;
flag=1;
}
Else if (flag==0)
continue;
The else
{
A [k] [j]='\ 0';
k++;
J=0;
flag=0;
}
for(i=0; i
Strcpy (b, a [0]);//for longest word
for(i=1; i
Strcpy (b, a [I]);
Puts (b);
}
CodePudding user response:
# include
#include
Void main ()
{
Char s [100], a [10] [10], [10] b;
Int I, j, k, len, flag.
Gets (s);//input string
Len=strlen (s);//get the length of the string
J=0; K=0; flag=0;
for(i=0; iIf (s [I] & gt;='a' & amp; & S [I] <='z' | | s [I] & gt;='A' & amp; & S [I] <='Z')//every citation letters, that part of the character for the word
{
A [k] [j] [I]=s;//words one by one in the two dimensional array of characters. A, a total of 10 words, every word is not more than 10 characters long, so a [10] [10]
j++;
flag=1;//not word the end
}
Else if (flag==0)//continue to take the next word
continue;
The else//end of a word save
{
A [k] [j]='\ 0';
k++;
J=0;
flag=0;
}
for(i=0; iPuts (a [I]);//output of each word
Strcpy (b, a [0]);//for longest word
for(i=1; iIf (strlen (a [I]) & gt; Strlen (b))//a comparative word length in each word and b
Strcpy (b, a [I]);//if longer than b in words, replace the words in b
Puts (b);//output longest word
}
CodePudding user response:
Is not a quotation letter, it is English lettersCodePudding user response:
Do you know what language is this, do you know what is the header file, do you know which is the main function, and do you know which is an array, or even you know how much array,Look, you are not "completely" look not to understand, you have to understand better,
Lying is not a good boy,
So,
Either you say clear specific where do not understand;
Either you go back to see who can read, then closed the book, by those who understand themselves in their own way of writing, debugging operation to the satisfaction, and then came back to see this,
CodePudding user response:
# include
#include
Int main (int arg c, char * argv [])
{
Char s [100], a [10] [10], [10] b;
Int I, j, k, len, flag.
Gets (s);//input a string: good morning teacther
Len=strlen (s);//the length of the string value
J=0; K=0; flag=0;//initialize
for(i=0; iIf (s [I] & gt;='a' & amp; & S [I] <='z' | | s [I] & gt;='A' & amp; & S [I] <='Z')//judge whether letters, is one's words, one character to judge
{
A [k] [j] [I]=s;//record each character of each word to a [0] [1]... A [0] [10], a word line.
j++;//good a [0] [0 to 10]
flag=1;//morning a [1] [0 to 10]
}//teacther a [2] [0 to 10]
Else if (flag==0)//if not the letter, to judge whether the word head
continue;
The else//or tail
{
A [k] [j]='\ 0';//the end of each word
k++;//into the next words to
J=0;//a [k] [0]
flag=0;//marks reset
}
/* this code execution of the above, an array of a result: a [10] [10]={" good \ 0, "
"Morning \ 0,"
"Teacther \ 0
"}
*/
for(i=0; iPuts (a [I]);//a [0] [0]... Good
//a [1] [0] morning
//a [2] [0] teacther
Strcpy (b, a [0]);//get a [0] first word copy to the array in the array b, as the initial value in the word length
for(i=1; iIf (strlen (a [I]) & gt; Strlen (b))//compared with other words a of the array length
Strcpy (b, a [I]);//find the longest word in the array b
Puts (b);//the longest word in the output teacther
return 0;
}