更多"编写函数int fun(int lim, int aa[MAX]),该"的相关试题:
[简答题]请编写一个函数int fun(int n),其中n为自然数。函数fun( )的功能是求出自然数n(包括n)以内所有素数的和,并返回其值。
注意;部分源程序已存在文件PROC11.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC11.cpp的内容如下:
//PROC11.cpp
#include<iostream>
using namespace std;
int fun(int n);
int main( )
int number;
cout<<"Enter the number which you want to caculate: /n";
cin>>number;
cout<<"The result is:"<<fun(number)<<end1;
return 0;
int fun(int n)
//* * * * * * * * *
[多项选择]编程题
请编写函数void fun (int x, int pp[], int *n),它的功能是:求出能整除x且不是奇数的各整数,并按从小到大的顺序放在pp所指的数组中,这些除数的个数通过形参n返回。
例如,若x中的值为24,则有6个数符合要求,它们是2,4,6,8,12,24。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
void fun (int x, int pp[], int *n)
{
}
main ( )
{
int x,aa[1000], n, i ;
clrscr( ) ;
printf("/nPlease enter an integer number : /n ") ;
scanf ("%d", &x) ;
fun (x, aa, &n) ;
for (i=0 ; i
[简答题]请编写函数void fun(int x, int pp[], int *n),它的功能是:求出能整除x且不是偶数的各整数,并按从小到大的顺序放在即所指的数组中,这些除数的个数通过形参n返回。
例如,若x中的值为30,则有4个数符合要求,它们是1, 3,5,15。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
void fun (int x, int pp[], int *n)
main( )
int x,aa[1000], n, i ;
clrscr( );
printf("/nPlease enter an integer
number : /n ") ;
scanf ("%d", &x) ;
fun (x, aa, &n) ;
for (i=0 ; i<n ; i++)
printf ("%d ", aa [i]);
printf ("/n ") ;
[简答题]请编写一个函数void fun(int m, int k, int xx[]),该函数的功能是将大于整数m且紧靠m的k个非素数存入所指的数组中。
例如,若输入15,5,则应输出16,18,20,21,22。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
void fun(int m,int k,int xx[])
main( )
int m,n,zz[1000];
clrscr( );
printf("/nPlease enter two integers:");
scanf("%d%d",&m,&n);
fun(m,n,zz);
for(m=0;m<n;m++)
printf("%d",zz[m]);
printf("/n");
[简答题]请编写函数void fun (int x,int pp[],int *n),它的功能是求出能整除x且不是奇数的各整数,并按从小到大的顺序放在pp所指的数组中,这些除数的个数通过形参n返回。
例如,若x中的值为24,则有6个数符合要求,它们是2, 4, 6, 8, 12, 24。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h> void fun(int x,int PP[],int *n)
main ( )
int x,aa[1000],n,i;
clrscr( ) ;
printf("/nPlease enter an integer number:
/n ") ;
scanf("%d",&X);
fun(x,aa,&n);
for(i=0;i<n;i++)
printf("%d",aa[i]);
printf("/n");
[多项选择]简单应用题
请编写一个函数int fun(int nFirst,int nSecond),求两个数的最小公倍数并返回这个值。
注意:部分源程序已存在文件test13_2.cpp中。如输入7和8时,结果是56。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
文件test13_2的内容如下:
#include
int fun(int nFirst,int nSecond);
void main( )
{
int nFirst, nSecond;
cout<<"Please input the first one/n";
cin>>nFirst;
cout<<"Please input the second one/n";
cin>>nSecond;
cout<<"最小公倍数:"<
[简答题]请编写一个函数int fun (int nFirst, int nSecond),求两个数的最小公倍数并返回这个值。
注意:部分源程序已存在文件test13_2.cpp中。如输入7和8时,结果是56。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
文件test13_2的内容如下;
#include<iostream.h>
int fun(int nFirst,int nSecond);
void main( )
{
int nFirst,nSecond;
cout<<"Please input the first one";
cin>>nFirst;
cout<<" Please input the second one";
cin>>nSecond;
cout<<"最小公倍数:"<<fun(nFirst,nSecond)<<endl;
}
int fun(int nFirst,int nSecond)
{
}
[简答题]请编写一个函数void fun(int aa[],int n,int x),其中n表示数组aa中元素的个数,函数的功能是:计算前x项的和并放在aa[x]中,aa数组中的元素值和x的值由主函数通过键盘读入。
注意:用循环和数组实现。
部分源程序已存在文件PROC3.cpp中。请勿修改主函数和其他函数中的任何内容,
仅在函数resort( )的花括号中填写若干语句。
文件PROC3.cpp中的程序清单如下:
//PROC3.CPP
#include <iostream>
using namespace std;
#define MAX 100
int main ( )
void fun(int aa[],int n, int x);
int bb[MAX],i,x,n;
cout<<"Please enter the counter of the number:/n";
cin>>n;
cout<<"Please enter the number:/n";
for(i=0;i<n;i++)
cin>>bb[i];
cout<<"Input the x:/n";
cin>>x;
fun(bb, n,x);
cout<<"The data after total: "<<bb[x]<<end1;
return 0;
void fun(int aa[],int n, int x)
//*********
[多项选择]编程题
请编写一个函数int fun(int *s,int t,int *k),用来求出数组的最小元素在数组中的下标并存放在k所指的存储单元中。
例如,输入如下整数:
234 345 753 134 436 458 100 321 135 760
则输出结果为6,100。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
int fun(int *s,int t,int *k)
{
}
main( )
{
int a[10]={234,345,753,134,436,458,100,321,135,760},k;
clrscr( );
fun(a, 10, &k);
printf("%d, %d/n ", k, a[k]);
}