所有的C函数都必须在被__________时才能执行其函数体,从而完成函数的功能。
查看答案
编程:输出100以内的全部素数,每个素数占3列。部分程序如下: #include #include int IsPrime (int m); int main() { int m;for(m = 2; m <= 100; m++){if ( )printf("%3d", m ); }printf ("\n");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; }
编程:验证哥德巴赫猜想,任意输入一个不小于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;}}输出: