Current location - Plastic Surgery and Aesthetics Network - Clothing company - Maxpoint clothes
Maxpoint clothes
# include & ltstdio.h & gt

# include & ltstring.h & gt

//int letters, numbers, spaces, others; //What is this?

void count(char str[]);

int main()

{

char string[20];

To get (a string);

Count (string);

Returns 0;

}

Invalid count (string [])

{

int len = strlen(str);

If(len==0) // If there is no input character output prompt, the function returns.

{

Printf ("Please enter a dialog box! \ n ");

Return;

}

int k = 0;

int a[20];

for(int I = 0; I & ltlenI++) // Loop: Find out which character in str is a space.

{

if(str[i]== ' ')

{

a[k]= I;

k++;

}

}

a[k]= strlen(str); //Take the position of one character after the last character of the string as the end of array A..

Int point;

int max

If(k==0) // Output the string directly without spaces.

{

max = len

Point = 0;

}

other

{

max = a[0]; //The length of the first word is assigned to max.

Point = 0; //Assign the starting position of the first word to the point.

for(int j = 1; j & ltk+ 1; J++) // Loop to find the longest word.

{

if(max & lt; (a[j]-a[j- 1]- 1))

{

max = a[j]-a[j- 1]- 1;

point = a[j- 1]+ 1;

}

}

}

Printf ("the biggest word is"); //Output the longest word

for(I = 0; I & ltmaxi++)

{

printf("%c ",str[point]);

Point++;

}

printf(" \ n ");

}

/* The program has been modified to output the longest word in an English conversation through compilation. I wrote exactly according to your idea, but I want to say that your idea is not very good. It took me more than 20 minutes, and vc6.0 compiled without errors and warnings! See you write the statement of the function in the main function, it shouldn't take long to learn. It's good for beginners to have their own ideas, and it doesn't matter if it's complicated. But to be honest, this program is a bit complicated. You should pay more attention to the basics, completely out of kindness to remind. Because beginners have to take many detours in learning, they can ignore the above suggestions! Hmm. How interesting

I have written a program before, which is to change all spaces into' \0', dynamically apply for memory to store every word, and simulate the way the command line obtains parameters.

I hope I can help you, come on! */