user-0 提问: 急，在线等！

回复:
user: user-1
content: 希望对你有帮助：https://blog.csdn.net/it_xiangqiang/category_10581430.html 希望对你有帮助：https://blog.csdn.net/it_xiangqiang/category_10768339.html

user: user-0
content: 已经自己搞定了，把判断出的素数装进一个数组里面就可以解决了！#include<stdio.h> int main() { 	int i,j,k=0,leap,a[100],sum=0,len=0,num=0,h=0; 	for(i=2;i<50;i++)//判断一个数是不是素数  	{ 		for(j=2;j<i;j++) 		{ 			leap=1; 			if(i%j==0) 			{ 				leap=0; 				break; 			} 		} 		if(leap==1)//把素数放进一个数组里面 ，这样可以避免判断两个素数  		{ 			a[k++]=i; 			len++; 		} 	} 	for(i=0;i<len;i++)// 引用素数  	{ 		for(j=i;j<len;j++) 		{ 			sum=a[i]+a[j]; 			if(sum>=6&&sum%2==0&&sum<=50) 			{ 			printf("%2d = %2d + %2d   ",sum,a[i],a[j]); 			h++; 			if(h%5==0)//每行输出五个  			{ 			printf("\n"); 			} 			} 		} 	}printf("\n"); }

user: user-0
content: 引用 1 楼 宾灬的回复:仅作参考：  #include<stdio.h>  // 3-50之间所有的素数 int arr_s[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49 };  //判断是否在素数数组中 int is_contain(int num){ 	int start = 0; 	int end = 15; 	int middle = (start+end)/2; 	while(start < end - 1){ 		if(arr_s[middle] == num){ 			return 1; 		}else if(arr_s[middle] < num){ 			start = middle; 			middle = (start+end)/2; 		}else{ 			end = middle; 			middle = (start+end)/2; 		} 	} 	 	return arr_s[middle] == num; 	 } int  main()  {     	int i,j,r,count = 0; 	j = 0; 	//把6-50之间的偶数列出 	int arr[23] = {0}; //23个偶数 	for( i = 6; i<=50; i++){ 		if(i%2 == 0){ 			arr[j] = i; 			//printf("%d,", arr[j]); 			j++; 		} 	} 	 	 	for(i = 0; i < 23; i++){ //23个偶数 		 		for(j=0; j < 16; j++){ //16个素数 			r = arr[i] - arr_s[j]; 			if(is_contain(r) && r >=arr_s[j]){ 				printf("%d + %d = %d\t", arr_s[j], r, arr[i]); 				count++; 				if(count % 5 == 0){ 					printf("\n"); 				} 			} 			 		} 	} 	return 0;  }  这个方法不实用，因为你列举素数，应该写代码来判断这个数是不是素数！我会判断一个数是不是素数，但是我不会怎么实现引用两个素数相加。

user: user-2
content: 引用 1 楼 宾灬 的回复:仅作参考：  #include<stdio.h>  // 3-50之间所有的素数 int arr_s[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49 };  //判断是否在素数数组中 int is_contain(int num){ 	int start = 0; 	int end = 15; 	int middle = (start+end)/2; 	while(start < end - 1){ 		if(arr_s[middle] == num){ 			return 1; 		}else if(arr_s[middle] < num){ 			start = middle; 			middle = (start+end)/2; 		}else{ 			end = middle; 			middle = (start+end)/2; 		} 	} 	 	return arr_s[middle] == num; 	 } int  main()  {     	int i,j,r,count = 0; 	j = 0; 	//把6-50之间的偶数列出 	int arr[23] = {0}; //23个偶数 	for( i = 6; i<=50; i++){ 		if(i%2 == 0){ 			arr[j] = i; 			//printf("%d,", arr[j]); 			j++; 		} 	} 	 	 	for(i = 0; i < 23; i++){ //23个偶数 		 		for(j=0; j < 16; j++){ //16个素数 			r = arr[i] - arr_s[j]; 			if(is_contain(r) && r >=arr_s[j]){ 				printf("%d + %d = %d\t", arr_s[j], r, arr[i]); 				count++; 				if(count % 5 == 0){ 					printf("\n"); 				} 			} 			 		} 	} 	return 0;  }  49不是素数，7 x 7 = 49

user: user-3
content: 仅作参考：  #include<stdio.h>  // 3-50之间所有的素数 int arr_s[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49 };  //判断是否在素数数组中 int is_contain(int num){ 	int start = 0; 	int end = 15; 	int middle = (start+end)/2; 	while(start < end - 1){ 		if(arr_s[middle] == num){ 			return 1; 		}else if(arr_s[middle] < num){ 			start = middle; 			middle = (start+end)/2; 		}else{ 			end = middle; 			middle = (start+end)/2; 		} 	} 	 	return arr_s[middle] == num; 	 } int  main()  {     	int i,j,r,count = 0; 	j = 0; 	//把6-50之间的偶数列出 	int arr[23] = {0}; //23个偶数 	for( i = 6; i<=50; i++){ 		if(i%2 == 0){ 			arr[j] = i; 			//printf("%d,", arr[j]); 			j++; 		} 	} 	 	 	for(i = 0; i < 23; i++){ //23个偶数 		 		for(j=0; j < 16; j++){ //16个素数 			r = arr[i] - arr_s[j]; 			if(is_contain(r) && r >=arr_s[j]){ 				printf("%d + %d = %d\t", arr_s[j], r, arr[i]); 				count++; 				if(count % 5 == 0){ 					printf("\n"); 				} 			} 			 		} 	} 	return 0;  }