更多"请编写一个函数void fun(int p[],int n,int c"的相关试题:
[简答题]请编写一个函数void fun(int p[],int n,int c),其中数组p的元素按由小到大的顺序排列,其元素个数为n。函数fun( )的功能是将c插入到数组p中,且保持数组的升序排列。
注意:部分源程序已存在文件PROC9.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句;
文件PROC9.cpp的内容如下:
//PROC9.cpp
#include <iostream>
#include <string>
using namespace std;
#define M 30
void fun(int p[ ],int n,int c);
int main ( )
int pp[M],n,i;
int fg, c;
cout<<"Please input n:/n";
cin>>n;
cout<<"Please input the n data:/n";
for (i=0; i<n; i++)
cin>>pp [i];
cout<<"Please input c:/n";
cin>>c;
fun (pp, n, c);
for (i=0; i<n; i++)
cout<<pp [i] << " " ;
cout<<end1;
return 0;
void fun(int p[ ],int n, int c)
//* * * * * * * * *
[多项选择]简单应用题
请编写一个函数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 m, int k, int xx[]),该函数的功能是:将大于整数m且紧靠m的k个非素数存入所指的数组中。
例如,若输入15,5,则应输出16,18,20,21,22。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
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
[简答题]请编写一个函数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 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");
[简答题]请编写一个函数int fun (int *s,int t,int *k),用来求出数组的最小元素在数组中的下标并存放在k所指的存储单元中。
例如,输入如下整数:
234 345 753 134 436 458 100 321 135 760
则输出结果为6,100。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
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("%dr %d/n", k, a[k]);
[简答题]请编写一个函数void fun(int m, int k, int xx[]),该函数的功能是:将大于整数m且紧靠m的k个素数存入所指的数组中。
例如,若输入17,5,则应输出19,23,29,3l,37。
注意:部分源程序给出如下。
请勿改动主函数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=O;m<n;m++)
printf("%d ",zz[m]);
printf("/n ");
}
[简答题]请编写一个函数fun(int score [][3],int num),该函数返回有一门成绩以上课程成绩在85分以上,其余课程成绩不低于70分的人数。数组score按行存放num名考生各自的三门期末考试成绩。
注意:部分源程序已存在文件test31_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
程序输出结果如下:
3
文件test31_2.cpp清单如下:
#include <iostream.h>
int fun(int score[] [3],int num)
{
}
void main ( )
{
int score[4] [3]={{70,89,92},{70,76,93},(80,86,98},{65,73,45});
cout<<fun(score,4)<<end1;
}
[简答题]请编写一个函数char *fun(char *s,int n)。函数fun( )的功能是将字符串s中的字符“循环左移”n位。例如,输入“ABCDE”,则循环左移2位应输出“CDEAB”,输入“1234567”,循环左移3位应输出“4567123”。
注意:部分源程序已存在文件PROC13.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC13.cpp的内容如下:
//PROC13.cpp
#include <iostream>
#include <string>
using namespace std;
char *fun(char *s,int n);
int main( )
char str[81];
int n;
cout<<"Enter a string(less than 80 char)/n”;
cin>>str;
cout<<"/n Enter n:";
cin>>n;
if(n>strlen(str))
cout<<"/n Data overflow";
return 0;
cout<<"The result is: "<<fun(str,n)<<end1;
return 0;
char *fun(char*s,int n)
//* * * * * *