Example: In the following given program, fun finds two prime numbers for an even number whose sum equals the even number and passes the two prime numbers back to the main function via the parameter pointer.

Note: Do not change the main function, add or delete lines, or change the structure of the program.

The code is as follows:

#include<stdio.h>
#include<math.h>
void fun(int x,int*y,int*z)
{
	int i,j,d,t;
	for(i=3; i<x/2; i=i+2)
	{
		t=1;
		for(j=2; j<sqrt((double)i); j++)if(i%j==0)
		t=0;
		if(t==1)
		{
			d=x-i;
			for(j=2; j<=sqrt((double)i); j++)if(d%j==0)
					t=0;
				if(t==1)
				{
					*y=i;
					*z=d;
				}
		}
	}
}
main()
{
	int x,y,z;
	do
	{
		printf("\nInput x: ");
		scanf("%d",&x);
	}while(x%2);
	fun(x,&y,&z);
	printf("\n\n%d=%d+%d\n",x,y,z);
}
Copy the code

The output running window is as follows:



Other exercises this week

C programming column

① In the following given program, fun compares two strings and returns the first address of the long string as the function value.

② Please add the main function, this function is used to invert the elements of a one-dimensional array, the result is still stored in the original array.

③ In the following given program, fun finds two prime numbers for an even number whose sum equals the even number and returns the two prime numbers via the parameter pointer to the main function.

④ Please add the main function, the function is: print 1 to 99 meet the square of the one digit is equal to its own all numbers.

⑤ In the following given program, fun is used to sort five strings in ascending order by bubbling.

C programming > 21 week ⑥ Please add the main function, this function function: from the keyboard input a string, that is, a specified character, and then delete this character and all the characters after all, the result is still saved in the original string.

C language programming > 20 week 7 following the given program, the function is the function of fun: first referred to in the y deposit characters in a string in reverse order, and then will be referred to in x characters and y referred to in the string of the characters, according to the cross merge sort order to z referred to in the array, long residual characters in z has pointed out the tail end of the array.

A +b=52,a+2b=60 a+b= 60 a+b=52 a+b= 60 In this case, a is 44 and B is 8.

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