题目内容

编程:验证哥德巴赫猜想,任意输入一个不小于6的偶数,将其表示成两个素数的和,如:6=3+3;8=3+5;18=7+13。部分程序如下: #include  #include  int IsPrime (int m); int main() {int n, i;scanf("%d", &n);for(i = 3;i <= n/2;i = i+2){if( )printf("%d %d\n", i, n-i);} return 0; } int IsPrime (int m) {int i, k;if ( m == 1 ) return 0;k = (int)sqrt (m);for( i = 2; i <= k; i++){if (m % i == 0)return 0;}return 1; }

查看答案
更多问题

读下列程序,写出程序的运行结果。#include void Func(void);int main(){int i;for (i=0; i<5; i++){Func();}}void Func(void){static int a = 1;int b = 2, c;c = a + b;a++;b++;printf("%d\n", c);}输出:

读下列程序,写出程序的运行结果。#include void fun(int x, int y);int a=5, b=8;int main( ){int a=15;fun(a, b);printf("a=%d, b=%d\n", a, b);}void fun(int x, int y){int temp;if(a>b){temp=a;x=y;y=temp;}}输出:

读下列程序,写出程序的运行结果。#include double fact(int n);int main(){ int n;scanf ("%d", &n);printf ("%.0f\n", fact (n) );return 0;}double fact(int n){double result;if (n==1 || n == 0)result = 1;elseresult = n * fact(n-1);return result;}输入:5输出:

读下列程序,写出程序的运行结果。#include void PrintStar (int m);int main (void){int i, n;scanf("%d", &n);for(i = 1; i <= n; i++)PrintStar(i);return 0;}void PrintStar (int m){int i;for (i = 1; i <= m; i++)putchar('*');putchar ('\n');}输入:5输出:

答案查题题库