题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-12-17 06:50:43

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

更多"请编写一个函数printdate(int year,int month"的相关试题:

[简答题]请编写一个函数int SeqSearch(int list[],int start,int n,int key),该函数从start开始,在大小为n的数细list中查找key值,返回最先找到的key值的位置,如果没有找到则返回-1。请使用for循环实现。
注意:部分源程序已存在文件test19_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数SeqSearch的花括号中填写若干语句。
文件test19_2.cpp的内容如下:
#include <iostream.h>
int SeqSearch(int list[], int start, int n, int key)


void main( )

int A[10];
int key, count=0, pos;
cout<<"Enter a list of 10 integers: ";
for(pos=0;pos<10;pos++)

cin>>A[pos];

cout<<"Enter a key: ";
cin>>key;
pos=0;
while( (pos=SeqSearch(A, pos,10,key))!=-1)

count++;
pos++;

cout<<key<<" occurs "<<count<<(count!=1" times":" time")<<" in the list."<<end1;

[简答题]【说明】
请编写一个函数int SeqSearch(int list[],int start,int n,int key),该函数从start开始,在大小为n的数组list中查找key值,返回最先找到的key值的位置,如果没有找到则返回-1。请修改程序中画线部分的错误并将不同情况下的输出结果补充完整。
【程序】
文件search.cpp的内容如下:
#include <iostream. h >
int SeqSearch( int list[ ] ,int start,int n,int key)

for(int i=start;i<=n;i++) //(1)

if( list[i] = key)//(2)

return i;


return -1;

void main( )

int A[10]
int key,count=0,pos;
cout <<" Enter a list of 10 integers:";
for(pos=0;pos<10;pos++)

cin >>A; //(3)

cout <<" Enter a key; ";
cin >> key;
pos=0;
while(( pos = SeqSearch ( A, pos, 10, key)) !=-1 )

count ++;
pos ++;

cout<<key<<"occurs" <<count<< (count!=1" times":" time") <<" in the list,"
<< endl;

第一种情况:输入2 3 12 6 8 45 8 33 7输入key:8
输出: (4)
第二种情况:输入2 3 126
[简答题]请编写一个函数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)


[填空题]设有说明:
struct DATE int year; int month; int day;;
请写出一条定义语句,该语句定义d为上述结构体类型变量,并同时为其成员year,month、day依次赋初值2006、10、1:______。
[填空题]设有说明
struct DATE int year;int month;int day;;
请写出一条定义语句,该语句定义d为上述结构体类型变量,并同时为其成员year、month、day依次赋初值2006、10、1:______。
[简答题]请编写一个函数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");

[简答题]请编写一个函数comm(int n,int k),该函数将用递归算法计算从n个人中选择k个人组成一个委员会的不同组合数,由n个人里选k个人的组合数=由(n-1)个人里选k个人的组合数+由(n-1)个人里选(k-1)个人的组合数。 注意:部分源程序已存在文件test41_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数comm的花括号中填写若干语句。 源程序文件test41-2.cpp清单如下: #include<iostream.h> int comm(int n, int k) { } void main ( ) { int n=7, k=3; cout<<"n=7,k=3"<<endl; cout<<comm(n,k)<<endl; }
[简答题]请编写一个函数is 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++)

fscanf(rf,"%d%cr,&m,&n);
num(m,n,xx);
for(m=0;m<n;m++)fprintf(wf,"%d",xx[m]);
fprintf(wf,"/n");

fclose(rf);
fclose(wf);

[多项选择]编程题 请编写一个函数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 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)

// * * * * *

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

我来回答:

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

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码