Home > Back-end >  Technology small white has just started to learn c, can have a big help to see where there is the pr
Technology small white has just started to learn c, can have a big help to see where there is the pr

Time:11-17

Topic is: programming to achieve the shortest words in the string output, the input string in main function, write a function to finish the shortest word search, if there are multiple same word length, the output is only the first word, shortest hypothesis between words separated by a space (one or more Spaces), findshort (s1, s2) function s1 string is the shortest word search, to find the shortest words stored in s2,



#include
#include
Char [500] s1 and s2 [20].
Void findshort (char [] s)
{
Int c, I, j, min;
C=strlen (s);
Min=0;
j=0;
for(i=0; i{

If (s [I] & gt; [I]=((s & gt;='a' & amp; & S [I] <='z') | | (s [I] & gt;='A' & amp; & S [I] <='Z')))
j++;
The else
{
If (minFor (int n=0; NS2 [n] [I - j + n]=s;
j=0;
}
}
}

Int main ()
{
Gets (s1);
Findshort (s1);
The printf (s2);
return 0;
}
  • Related