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

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

请编写函数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);

}


参考答案

更多 “ 请编写函数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);} ” 相关考题
考题 请编写一个函数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(),它的功能是:求出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]);}

考题 请编写实现void * malloc(int)内存分配函数功能一样的代码。

考题 请编写函数countValue(),它的功能是:求n以内(不包括n)同时能被3与7整除的所有自然数之和的平方根s,并作为函数值返回,最后结果s输出到文件OUT11.DAT中。例如,若n为1000时,函数值应为s=153.909064。注意:部分源程序已给出。请勿改动主函数main()和输入输出函数progReadWrite()的内容。试题程序:include<conio.h>include<math.h>include<stdio.h>double countValue(int n){}main ( ){clrscr();printf ("自然数之和的平方根=%f\n", countValue(lO00)) ;pregReadWrite();}pregReadWrite(){FILE *wf;int i, n;float s;wf = fepen("OUT11.DAT", "w");s = ceuntValue(1000);fprintf(wf, "%f\n", s);fclese(wf);}

考题 请编写一个函数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");}

考题 请编写函数count Value(intn),它的功能是:求n以内(不包括n)同时能被3与7整除的所有自然数之和的平方根s, s作为函数返回值,最后结果S输出到文件out.dat中。 例如若n为1000时,函数值应为:s=153.909 064。

考题 请编写函数void proc(int x,int pp[],int*n),它的功能是:求出能整除x且不是偶数、不为1的各整数,并按从大到小的顺序放在PP所指的数组中,这些除数的个数通过形参n返回。例如,若x的值为30,则有3个数符合要求,它们是15,5,3。注意:部分源程序给出如下。请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。试题程序: