Example: The following given program reads a line of English text, capitalizes the first letter of each word, and prints the line (where “words” are strings separated by Spaces).

For example, if you enter Good luck! “, Good Luck! . Note: Do not change the main function, add or delete lines, or change the structure of the program.

The code is as follows:

#include<ctype.h>
#include<string.h>
#include<stdio.h>
void top(char*s)
{
	int i=0;
	for(; *s; s++)if(i)
		{
			if(*s==' ')
			i=0;
		}
		else
		{
			if(*s! =' ')
			{
				i=1;
				*s=toupper(*s);
			}
		}
}
main()
{
	char str[81];
	printf("\nPlease enter an English text line: ");
	gets(str);
	printf("\n\nBefore changing:%s",str);
	top(str);
	printf("\n\nAfter changing:%s\n",str);
}
Copy the code

The output running window is as follows:



Other exercises this week

C programming column

In the given program, fun inserts an * after each non-numeric character in the string referenced by parameter s.

Fun converts the uppercase letter to the fifth letter after the corresponding lowercase letter. If the lowercase letter is v ~ z, the lowercase letter value is reduced by 21. The converted lowercase letter is returned as the function value.

③ In the following given program, the function of fun is: according to the input of the three sides of the length (integer value), can determine whether to form a triangle; Is it an equilateral triangle or an isosceles triangle? Return 3 if you can form an equilateral triangle, 2 if you can form an isosceles triangle, 1 if you can form a triangle, and 0 if you can’t form a triangle.

C programming > 25 weeks ④ Please add fun function, this function function is divisible k and even numbers, save these numbers in array A, and print from large to small.

⑤ The function of the following given program is to read a line of English text, uppercase the first letter of each word, and then print the line (where “words” are strings separated by Spaces).

Count the number of primes less than or equal to x(x > 2) and return the number of primes as a function value.

⑦ The function fun in the following given program is to calculate m! .

The function fun in the following given program is: the long integer number in each digit of the even number, form a new number put in B. The high is still high, the low is still low.

The harder you work, the luckier you get! Come on, Aoli!!