网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

请编写一个函数fun(),它的功能是:求出1到m(含m)之内能被7或11整除的所有整数放在数组a中,通过n返回这些数的个数。

例如,若传给m的值为50,则程序输出:

7 11 14 21 X 28 33 35 42 44 49

注意:部分源程序给出如下。

请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。

试题程序:

include<conio.h>

include<stdio.h>

define M 100

void fun(int m, int *a, int *n)

{

}

main()

{

int aa[M],n,k;

clrscr();

fun(50,aa,&n);

for(k=0;k<n; k++)

if((k+1)%20==0) /*每行输出20个数*/

{printf("%4d",aa[k]);

printf("\n");

}

else

printf("%4d",aa[k]);

printf("\n");

}


参考答案

更多 “ 请编写一个函数fun(),它的功能是:求出1到m(含m)之内能被7或11整除的所有整数放在数组a中,通过n返回这些数的个数。例如,若传给m的值为50,则程序输出:7 11 14 21 X 28 33 35 42 44 49注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<conio.h>include<stdio.h>define M 100void fun(int m, int *a, int *n){}main(){int aa[M],n,k;clrscr();fun(50,aa,n);for(k=0;k<n; k++)if((k+1)%20==0) /*每行输出20个数*/{printf("%4d",aa[k]);printf("\n");}elseprintf("%4d",aa[k]);printf("\n");} ” 相关考题
考题 请编写一个函数proc,它的功能是:求出1~m(含m) 能被7或11整除的所有整数放在数组a中,通过n返回这些数的个数。 例如,若传给m的值为70,则程序输出: 7 11 14 21 22 28 33 35 42 44 49 55 56 63 66 70 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填人所编写的若干语句。 试题程序: includestdlib.h includeconio.h includestdio.h define N 100 void proc(int m,int*a,int*n) {} void main { int arr[N],n,k; system("CLS"); proc(70,arr,&n); for(k=0;kn;k++) if((k+1)%20==0)//每行输出20个数 { printf("%4d",arr[k]); printf("\n"); } else printf("%4d",arr[k]); printf("\n"); }

考题 请编写一个函数fun(),它的功能是:求出一个4×M整型二维数组中最小元素的值,并将此值返回调用函数。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仪在函数fun的花括号中填入所编写的若干语句。试题程序:define M 4include<stdio.h>fun (int a[])[M]){}main(){int arr[4][M]={11,3,9,35,42,-4,24,32,6,48,-32,7,23,34,12,-7);printf(“min=%d\n”,fun(arr));}

考题 编写函数fun(),它的功能是:求出1~1000之内能被7或11整除,但不能同时被7和11整除的所有整数,并将它们放在a所指的数组中,通过n返回这些数的个数。[注意] 部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。[试题源程序]include <conio.h>include <stdio.h>void fun(int *a, int *n){}main(){int aa[1000], n, k;clrscr();fun(aa,&n);for(k=0; k<n; k++)if(k+1)%10==0){printf("%5d", aa[k]);printf("\n");}elseprintf("%5d", aa[i]);}

考题 请编写函数fun(),它的功能是:求出1到1000之内能被5或13整除、但不能同时被5和13整除的所有整数并将它们放在 9所指的数组中,通过n返回这些数的个数。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <stdio.h>void fun(int *a,int *n){}main( ){int aa[1000],n,k;clrscr();fun(aa,an);for(k=0;k<n;k++)if((k+1)%10==0){printf("%5d",aa[k]);printf("\n"); /*—行写10个数*/}elseprintf("%5d",aa[k]);}

考题 请编写函数fun(),它的功能是:求出1到1000之内能被7或11整除、但不能同时被7和11整除的所有整数并将它们放在 a所指的数组中,通过n返回这些数的个数。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <stdio.h>void fun (int *a,int *n){}main(){int aa[1000], n, k;clrscr();fun(aa,n);for(k=0;k if((k+1)%10==0){printf("%5d",aa[k]);printf("\n");} /*一行写9个数*/elseprintf("%5d ",aa[k]);}

考题 请编写函数fun,它的功能是:计算并输出n(包括n)以内能被5或9整除的所有自然数的倒数之和。例如,在主函数中从键盘给n输入20后,输出为:s=0.583333。注意:要求n的值不大于100。部分源程序在文件PROGl.C中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。

考题 请编写函数void countValue(int *a,int *n),它的功能是:求出1到1000之内能被7或11整除但不能同时被7和11整除的所有整数并存放在数组a中,并通过n返回这些数的个数。注意:部分源程序已给出。请勿改动主函数main()和写函数writeDAT()的内容。试题程序:include<conio.h>include<stdio.h>void countValue(int *a, int *n){}main ( ){int aa[1000],n, k;clrscr();countValue (aa, n);for(k=0;k<n; k++)if((k+1) %10 ==0){printf("%5d",aa[k]);printf("\n");}else printf("%5d",aa[k]);writeDAT();}writeDAT ( ){int aa[1000],n, k;FILE *fp;fp=fopen("out79.dat","w");countValue(aa,n);for(k=0; k<n; k++)if((k+1)%10==0){fprintf(fp,"%5d",aa[k]);fprintf(fp,"\n");}else fprintf (fp,"%5d",aa[k]);fclose(fp);}

考题 请编写一个函数fun(),它的功能是:求出一个2×M整型二维数组中最大元素的值,并将此值返回调用函数。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fan的花括号中填入所编写的若干语句。试题程序:define M 4include <stdio.h>fun(int a[] [M]){}main(){int arr[2][M]={5, 8, 3, 45, 76, -4, 12, 82};printf("max=%d\n",fun(arr));}

考题 请编写函数fun( ),其功能是:将所有大于1小于整数m的素数存入xx所指数组中,素数的个数通过k传回。例如,输入25,则应输出2 3 5 7 11 13 17 19 23。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<conio.h>include<stdio.h>void fun(int m,int *k,int xx[ ]){}main( ){int m,n,zz[100];clrscr( );printf("/nPlease enter an integer number between 10 and 100:");scanf("%d",n);fun(n,m,zz);printf("\n\nThere are%d prime numbersless than %d:",m,n);for(n=0;n<m;n++)printf("\n %4d",zz[n]);}