题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-01-04 19:20:16

[简答题]请编写一个函数maxofarray(atype*p,int count),该函数从一个数组中找出其中的最大元素,并且数组中可以存放多种数据类型的元素。
注意:部分源程序己存在文件test42_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数maxofarray的花括号中填写若干语句。
文件test42_2.cpp清单如下:
#include<iostream.h>
#include<string.h>
#include<conio.h>
template<class atype>
void maxofarray(atype* p,int count)


void main ( )

int len=5;
char *p1;
cout<<"the char type array and it’s length is 5:/n";
cout<<"the array element is a b c d e/n";
p1=new char[len];
for (int i=0;i<len;i++)
p1[i]=’a’+i;
maxofarray(p1,len);

更多"请编写一个函数maxofarray(atype*p,int count"的相关试题:

[简答题]请编写一个函数maxofarray(atype*p,int count),该函数从一个数组中找出其中的最大元素,并且数组中可以存放多种数据类型的元素。
注意:部分源程序己存在文件test42_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数maxofarray的花括号中填写若干语句。
文件test42_2.cpp清单如下:
#include<iostream.h>
#include<string.h>
#include<conio.h>
template<class atype>
void maxofarray(atype* p,int count)


void main ( )

int len=5;
char *p1;
cout<<"the char type array and it’s length is 5:/n";
cout<<"the array element is a b c d e/n";
p1=new char[len];
for (int i=0;i<len;i++)
p1[i]=’a’+i;
maxofarray(p1,len);

[多项选择]简单应用题 请编写一个函数int Count(double a[], int n),统计出具有n个元素的一维数组中大于等于所有元素平均值的元素个数并返回这个值。注意:请使用for循环实现该函数。 注意:部分源程序已存在文件test12_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数Count的花括号中填写若干语句。 文件test12_2的内容如下: #include int Count(double a[], int n) { } void main( ) { double a[5]; cout<<"请输入5个double型的数字"<>a[i]; } int result=Count(a,5); cout<<"大于等于所有元素平均值的元素个数:"<
[简答题]请编写一个函数int Count(double a[],int n),统计出具有n个元素的一维数组中大于等于所有元素平均值的元素个数并返回这个值。注意:请使用for循环实现该函数。 注意:部分源程序已存在文件test12_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数Count的花括号中填写若干语句。 文件test12_2的内容如下: #include<iostream.h> int Count(double a[], int n) { } void main( ) { double a[5]; cout<<"请输入5个double型的数字"<<endl; for(int i=0;i<5;i++) { cin>>a[i]; } int result=Count(a,5); cout<<"大于等于所有元素平均值的元素个数:"<<result<<endl; }
[多项选择]简单应用题 请编写一个函数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<<"最小公倍数:"<
[简答题]请编写一个函数printdate(int year,int month,int day),该函数实现将输入的3个数字转换成英语数字纪年输出的功能,如输入March9,1978,则输出1978 3 9。注意:使用switch结构实现该函数的基本功能并应该能够判断错误的输入。部分源程序已存在文件test40_2.cpp中。请勿修改主函数main和其他函数中的任何内容,仅在函数printdate的花括号中填写若干语句。
源程序文件rest40_2.cpp清单如下:
#include<iostream.h>
void printdate(int year, int month, int day)


void main( )

printdate(1978,3,9);

[简答题]请编写一个函数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)


[简答题]请编写一个函数int fun(int *s,int t,int *k),用来求出数组的最大元素在数组中的下标并存放在k所指的存储单元中。
例如,输入如下整数:
876 675 896 101 301 401 980 431 451 777
则输出结果为6,980。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
int fun(int *s,int t,int *k)


main( )

int a[10]= 876,675,896,101,301,401,
980,431,451,777,k;
clrscr( );
fun(a, 10, &k);
printf("%d, %d/n ", k, a[k]);

[简答题]请编写一个函数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)

//* * * * * * * * *

[简答题]请编写一个函数int stringLen(char*ps),该函数能计算出字符串ps的长度,函数返回值就是字符串的长度(不包括字符串结束标识号’/0’)。本题要求:用指针方式及循环来实现该函数。
注意;部分源程序已存在考生文件夹下的文件PROC6,cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数stringLen( )的花括号中填写若干语句。
文件PROC6.cpp的内容如下:
//PROC6.cpp
#include<iostream>
using namespace std;
int stringLen(char *);
int main( )

char str[100],*p;
cout<<"Input your string please!/n";
cin>>str;
p=str;
cout<<"The lenth of your string is "<<stringLen(p)<<end1;
return 0;

int stringLen(char *ps)

// * * * * *

[简答题]简单应用题 请编写一个函数 int sum(int n),该函数完成1+2+3+…+n的运算,并返回运算结果,其中n>0。注意:请使用递归算法实现该函数。 注意:部分源程序已存在文件test11_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数sum的花括号中填写若干语句。 文件test11_2.cpp的内容如下: #include int sum(int n) { } void main( ) { int n; cout<<"输入n: "; cin>>n; int result=sum(n); cout<<"结果为:"<
[简答题]请编写一个函数int CalcDigital(char *str),该函数可返回字符串str中数字字符(即0~9这10个数字)的个数,如字符串“olympic2008”中数字字符的个数为4。请用if条件判断语句与for循环语句来实现该函数。 注意:部分源程序已存在文件test9_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数find的花括号中填写若干语句。 文件test9_2.cpp的内容如下: #include<iostream.h> #include<string.h> int CalcDigital(char*str); void main( ) { char *str; str=new char[255]; cout<<"输入字符串:"; cin>>str; int num=CalcDigital(str); cout<<str<<":"<<num<<endl; } int CalcDigital(char *str) { }
[多项选择]编程题 请编写一个函数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 sum(int n),该函数完成1+2+3+…+n的运算,并返回运算结果,其中n>0。注意:请使用递归算法实现该函数。
注意:部分源程序已存在文件:test11.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数sum的花括号中填写若干语句。
文件test11_2.cpp的内容如下:
#include<iostream.h>
int sum(int n)


void main( )

int n;
cout<<"输入n:";
cin>>n;
int result;sum(n);
cout<<"结果为:"<<result<<endl;

[简答题]请编写一个函数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");

[简答题]

请编写一个函数jS Value(int m, int k, int xx[]),该函数的功能是:将小于整数m且紧靠m的k个素数存入数组xx并传回。调用函数writeDat( )读取10组数据,分别得出结果且把结果输出到文件out.dat中。
注意:部分源程序给出如下。
例如:若输入“17,5”,则应输出“13,11,7,5,3”。
请勿改动主函数main( )和输出数据函数readwriteDat( )的内容。
[试题源程序]
#include<conio.h>
#include<stdio.h>
void readwriteDat( );
void num(int m, int k, int xx[])


main( )

int m, n, xx[1000];
System("cls");
printf("/nPlease enter two integers:");
Scanf("%d%d", &m, &n);
num(m,n,xx);
for(m=0;m<n;m++)
printf("%d",xx[m]);
printf("/n");
readwriteDat( );

void readwriteDat( )

int m,n,xx[1000],i;
FILE *rf,*wf;
rf=fopen("in.dat","r");
wf=fopen("out.dat","w");
for(i=0;i<10;i++)

Scanf(rf,"%d%d",&m,&n);
num(m,n,xx);

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码