Example: Fun in the following given program stores characters in STR in reverse order into S, and concatenates characters in STR in positive order after S.

For example, if the string in STR is ABCDE, the string in S should be EDCBAABCDE. Note: Do not change the main function, add or delete lines, or change the structure of the program.

The code is as follows:

#include<conio.h>
#include<stdio.h>
#include<string.h>
void fun(char*str,char*s)
{
	int s1,i;
	s1=strlen(str);
	for(i=0; i<s1; i++) s[i]=str[s1-i- 1];
	for(i=0; i<s1; i++) s[s1+i]=str[i]; s[2*s1]='\ 0';
}
main()
{
	char str[100],s[100];
	printf("\nPlease enter string str:");
	scanf("%s",str);
	fun(str,s);
	printf("The result is:%s\n",s);
}
Copy the code

The output running window is as follows:



Other exercises this week

C programming column

① Please add fun function, this function is to determine whether a number is prime. When the number is prime, the function returns the string “yes!” Otherwise the function returns the string “No!” And output it in the main function.

(fun) (string s) (STR) (string S) (fun) (string S) (STR) (string S) (string S) (fun) (STR) (string S) (string S) (string S) (string S)

③ The function of the given program is to segment the scores of m individuals, test scores in the score array, the number of segments stored in the a array:

In the following given program, the function of fun is: given n real numbers, output average, and count the number of real numbers above average (including average).

Find the element whose value is a in s, return the number of elements whose value is a, and store the subscripts of these elements in sequence in array STR.

Use recursive algorithm to calculate the value of the NTH term in the Fibonacci series. From the first term, the Fibonacci series is 1, 1, 2, 3, 5, 8…

Fun moves all non-numeric characters in the string referred to by S after all numeric characters, and preserves the original sequence of numeric and non-numeric strings.

Fun computes and outputs the sum of the 10 largest primes up to Max. High passes from the main function to fun.

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