题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-09-27 19:22:42

[简答题]请编写一个函数resort,该函数的功能是:能在一个数列中,对从指定位置开始的几个数,按相反顺序重新排列,并在主函数中输出新的数列。
注意:部分源程序已存在文件PROC4.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数reson( )的花括号中填写若干语句。
文件PROC4.cpp的内容如下:
//PROC4.cpp
#include<iostream>
using namespace std;
void resort(int array[],int where,int arrount);
int main( )

int number[20],where, arrount,i;
cout<<"input 20 numbers/n";
for(i=0;i<20;i++)
cin>>number[i];
cout<<"how many do you want to sort:";
cin>>arrount;
cout<<"where do you want to start:";
cin>>where;
resort(number,where,arrount);
cout<<"/n resorted array as follow:/n";
for(i=0;i<20;i++)
cout<<number[i];
return 0;

void resort(int array[ ],int where,int amount)

/************/

更多"请编写一个函数resort,该函数的功能是:能在一个数列中,对从指定位"的相关试题:

[简答题]请编写一个函数resort,该函数的功能是:能在一个数列中,对从指定位置开始的几个数,按相反顺序重新排列,并在主函数中输出新的数列。 注意:部分源程序已存在文件PROC4.cpp中。 请勿修改主函数和其他函数中的任何内容,仅在函数reson( )的花括号中填写若干语句。 文件PROC4.cpp的内容如下: //PROC4.cpp #include<iostream> using namespace std; void resort(int array[],int where,int arrount); int main( ) { int number[20],where, arrount,i; cout<<"input 20 numbers/n"; for(i=0;i<20;i++) cin>>number[i]; cout<<"how many do you want to sort:"; cin>>arrount; cout<<"where do you want to start:"; cin>>where; resort(number,where,arrount); cout<<"/n resorted array as follow:/n"; for(i=0;i<20;i++) cout<<number[i]; return 0; } void resort(int array[ ],int where,int amount) { /************/ }
[单项选择]下面程序的功能是由随机函数产生100个在200~700之间的整数,然后找出最大者,并记下是第几个数,但程序不完整,请选择适当的内容在下划线处将程序补充完整。 Dim a(100) For j=1 To 100 a(j)=Int(Rnd*501+200):Print a(j) Next j : Print p=1 : max= ______ For j=2 To 100 If a(j)>max Then max=a(j) : p=j Next j Print "The largest number is " ; max Print "The position is"; p End
A. 0
B. a(1)
C. 1.7E+38
D. 1.7E-38
[简答题]给定一个函数,其函数功能为:使10个整数按由小到大的顺序排列。在主函数中输入10个数,并输出结果。使用VC6打开考生文件夹下的工程RevProj5。此工程包含一个源程序文件RevMain5.cpp,该程序实现上述功能。但此程序运行有问题。请找出错误的地方,改正后将此程序调试正确。
注意:不得删行或增行,也不得更改程序结构。
文件RevMain5.cpp中的程序清单如下:
//RevMain5.cpp
#include<iostream>
#include<iomanip>
using namespace std;
int main( )

void sort(int array[],int n);
int data[10],*p,i;
cout<<"Input 10 numbers/n";
for (i=0; i<10; i++)
cin>>data [i];
cout<<"the origined array is:";
for (p=data;p<data+10;p++)

if((p-&data[0]) %5==0)
cout<<" /n";
cout<<setw (5) <<*p;

sort (data, 10);
cout<<"/n the present array is:";
for(p=data;p〈data+10;p++)

if((p-&data[0])%5==0) cout<<"/n";
cout<<setw (5)<<*p;


void sort(int array[],int n)

/* * * * * * * * *found * * * * * * * * * */
for(p1=array;p1<array+(n-1) ;p1++)

for (p2=p1+1 ;p2<array+n;p
[简答题]自定义一个函数,函数的形参为字符数组s1和s2,函数功能是将字符串s1中的所有数字字符取出,存入另一字符数组s2中,使s2成为一个新的字符串,并在函数中将字符串s2输出。
[单项选择]一个函数功能不太复杂,但要求被频繁调用,应选用()。
A. 内联函数
B. 重载函数
C. 递归函数
D. 嵌套函数
[简答题]编写一个函数findStr( ),该函数的功能是:统计一个以单词组成的字符串中(各单词之间以空格隔开)所含指定长度单词的个数。例如,输入字符串为"you are very good you",指定要查找的单词的长度为3,则函数返回值是3。
函数readWriteData( )的功能是从IN.DAT中读取字符串和子字符串,并把统计结果输出到屏幕和文件OUT.DAT中。
注意:部分源程序已给出。
请勿改动主函数main( )和函数WriteData(int n)中的内容。
试题程序:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void readWriteData( );
int findStr(char*str,int find_len)


void main( )

char str[81];
int find_len;
int n;
system("CLS");
printf("input the strings:");
gets(str);
printf("input the length:");
seanf("%d",&find_len);
puts(str);
printf("length=%d",find_len);
n=findStr(str,find_len);
printf("n=%d",n);
readWriteData( );

void readWriteData( )

char str[81],substr[11];
int n,len,i=0;
FILE*rf,*wf;
rf=fopen("IN.DAT","r");
wf=fopen("OUT.DAT","W");
while(i<3)

fgets(str,80,rf);
fgets(substr,10,rf)
[简答题]请编写一个函数char *fun(char *s),其中s代表一个字符串。函数fun( )的功能是将字符串s的元素倒置。例如,输入为“teacher”,则应输出“rehcaet”。 注意:部分源程序已存在文件PROC10.cpp中。 请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。 文件PROC10.cpp的内容如下: //PROC10. cpp #include <iostream> #include <string> using namespace std; char *fun(char *s); int main ( ) { char str[81]; cout<<"Please enter a string:/n"; cin>>str; cout<<"The result is:"<<fun(str)); cout<<end1; return 0; } char*fun(char*s) { //* * * * * * * * * }
[简答题]下列程序定义了N×N的二维数组,并在主函数中赋值。请编写一个函数fun( ),函数的功能是:求数组周边元素的平方和并作为函数值返回给主函数中的值。例如,若数组a中的值为
0  1  2  7  9
1  11  21  5  5
2  21  6  11  1
9  7  9  10  2
5  4  1  4  1
则返回主程序后s的值应为310。
注意:部分原程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
[试题源程序]
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
int fun(int w[][N])


main( )

int a[N][N]=0,1,2,7,9,1,11,21,5,5,2,21,6,11,1,9,7,9,10,2,5,4,1,4,1;
int i,j;
int s;
clrscr( );
printf("*****The array*****/n");
for(i=0;i<N;i++)

for(j=0;j<N;j++)

printf("%4d",a[i][j]);

printf("/n");

S=fun(a):
printf("*****THE RESULT*****/n");
printf("The sum is:%d/n",s);

[简答题]请编写一个函数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 compare(char *s,char *t)), 该函数的功能是对两个字符串进行比较。当s所指字符串和t所指字符串相等时,返回值为0;当s所指字符串大于是t指字符串时,返回值大于0;当s所指字符串小于t所指字符串时,返回值小于0。 注意:部分源程序已存在文件PROC8.cpp中。 文件PROC8.cpp的内容如下: //PROC8.cpp #include <iostream> #include <string> using namespace std; int compare(char *s,char *t) { //* * * * * * * * * } int main ( ) { char str1[100],str2[100]; int result; cout<<"Input the first string/n"; cin>>str1; cout<<"Input the second string/n"; cin>>str2; result=compare(str1,str2); if (result==0) cout<<"string1=string2 ! /n"; else if (result>0) cout<<"string1>string2 ! /n"; else cout<<"string1<string2 ! /n"; return 0; }

我来回答:

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

订单号:

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