题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-07-30 21:03:00

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。完成函数fun(char *s1,char *s2)的空出部分。函数fun(char *s1,char *s2)的功能是将在字符串s1中下标为偶数的字符,紧随其后重复出现一次,放在一个新串s2中,s2中字符按原字符串中字符的顺序排列。(注意0为偶数)
例如:当s1中的字符串为“abcdef”时,s2中的字符串应为“aaccee”。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<iostream.h>
void fun(char *s1,char *s2)


void main( )

char sl[100],s2[l00];
cout<<"Please enter string string:"<<end1;
cin.getline(s1,100);
fun(s1,s2);
cout<<"The result is:"<<s2<<end1;
return;

更多"使用VC++6.0打开考生文件夹下的源程序文件2.cpp。完成函数fu"的相关试题:

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。完成函数fun(char *s1,char *s2)的空出部分。函数fun(char *s1,char *s2)的功能是将在字符串s1中下标为偶数的字符,紧随其后重复出现一次,放在一个新串s2中,s2中字符按原字符串中字符的顺序排列。(注意0为偶数)
例如:当s1中的字符串为“abcdef”时,s2中的字符串应为“aaccee”。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<iostream.h>
void fun(char *s1,char *s2)


void main( )

char sl[100],s2[l00];
cout<<"Please enter string string:"<<end1;
cin.getline(s1,100);
fun(s1,s2);
cout<<"The result is:"<<s2<<end1;
return;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。完成函数fun(char *s,int a[]),其功能是把字符串s中的数字提取出来存储在a[]中,然后返回数字的个数。
例如s="1234abcdef567",则a[]中存储着1234567,返回7。
注意:不能修改程序的其他部分,只能修改fun函数。
试题程序:
#include<iostream.h>
int fun(char *s,int a[])


int main( )

int a[1024];
int len=fun("1234abcdef567",a);
for(int i=0;i<len;i++)

cout<<a[i]<<’’;

cout<<end1;
cout<<i<<end1;
return 0;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(char *data),此函数的功能是找出字符串数组中最大的ASCⅡ值,如果有相同变量,则输出最后一个所在的位置;如果字符串为空,则返回-1;或者不存在时也返回-1。
注意:不能修改函数的其他部分。计算数字如果第一个字母最大,则返回0。依次增加。
试题程序:
#include<iostream.h>
int fun(char *data)


void main( )

char source[1024];
cout<<"请输入一行英文字符串:/n";
cin.getline(source,1024);
cout<<"最大的字母出现在距离头部"<<fun(source)<<"个字母处"<<end1;
[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。完成空出函数fun(char *s,char *t)部分。函数fun(char *s,char *t)的功能是将在字符串s中下标为偶数位置上的字符,紧随其后重复出现一次,放在一个新串t中,t中字符按原字符串中字符的顺序排列。
例如:当s中的字符串为“ABCDEF”时,t中的字符串应为“AACCEE”。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<iostream.h>
void fun(char *s,char *t)


void main( )

char s[100],t[100];
cout<<"Please enter string s:"<<end1;
cin.getline(s,100);
fun(s,t);
cout<<"The result is:"<<t<<end1;
return;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(char *s),使其具有以下功能:
(1)把s中的大写字母转换成小写字母,把其中的小写字母转换成大写字母,并且在函数中调用写函数WriteFile( )将结果输出到2.txt文件中。
例如:s="helloWORLD",则结果为“s="HELLOworld"”。
(2)完成函数WriteFile(char *s),把字符串输入文件中。
提示:打开文件使用的第二参数为“ios_base::binary|los_base::app”。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<iostream>
#include<fstream>
#include<cmath>
using namespace std;
void WriteFile(char *s)


void fun(char *s)


void ClearFile( )

ofstream out1;
out1.open("2.txt");
out1.close( );

int main( )

ClearFile( );
char s[1024];
cout<<"please input a string:"<<end1;
cin.getline(s,1024);
fun(s);
return 0;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。阅读下列函数说明代码。函数num(char *str)用于返回字符串中非数字的个数。
例如:abc123abc45
返回值为:6
将函数num补充完整。
注意:请勿改动主函数。
试题程序:
#include<iostream.h>
int num(char *str)

int main( )
char str[1024];
cout<<"please input a string:"<<end1;
cin.getline(str,1024);
cout<<"char number is"<<num(str)<<end1;
return 0;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数un(char*str1,char*str2),此函数的功能是计算str1中出现str2的个数,当不出现时,则返回0。

str1为“asdfsfdfg”
str2为“sf”则返回1
str2为“df”则返回3
注意:不能修改函数的其他部分。
试题程序:
#include<iostream.h>
//注意只能使用int类型,不能类型转换
int fun(char*str1,char*str2)


void main( )

char str1[l024];
char str21256];
cout<<"please input a string:"<<end1;
cin.getline(str1,1024);
cout<<"please input other string:"<<end1;
cin.getline(str2,256);
cout<<fun(str1,str2);
cout<<end1;
return;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(cbar *str,char ch)的定义,本函数采用二分法,在已按字母次序从小到大排序的字符数组str中,查找字符ch,若ch在数组中,函数返回字符ch在数组中的下标,否则返回1。
二分法查找的思想是初始查找区间的下界为0,上界为len-1,查找区间的中部后,k=(下界+上界)/2;若list[k]等于ch,查找成功;若list[k])ch,则新的查找区间的下界不变,上界改为k-1;否则新的查找区间的下界改为k+1,上界不变。在新区间内继续用二分法查找。
注意:请勿改动主函数main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#inclLlde<iostream.h>
int fun(char *str,chat ch)


void main( )

char str[]=’a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’;
char ch;
cout<<"请输入一个字符:"<<end1;
cin>>ch;
cout<<"输入字符的位置是:"<<fun(str,ch)<<end1;
return;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp,请实现函数fun(double a[],int len)的如下功能:
(1)a[]是一个数组,长度为len。
(2)a[0]=0,a[1]=1。
(3)a[i+2]=a[i]+a[i+1]。
注意:不能修改函数的其他部分。
试题程序:
#include<iostream>
void fun(double a[],int len)


void main( )

double a[20];
fun(a,20);
for(int i=0;i<20;i++)

std::cout<<a[i]<<’’;
if(i%6==5)
std::cout<<std::end1;

return;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(int x)的定义,该函数功能是判定x的所有约数,并且在函数中调用写函数WriteFile将结果输出到2.txt文件中。
例如:x=100的约数为1 2 4 5 10 20 25 50 100。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<iostream>
#include<fstream>
#include<cmath>
using namespace std;
void WriteFile(int c)

ofstream out1;
out1.open("2.txt",ios_base::binary|ios_base::app);
out1<<c<<’’;
out1.close( );

void fun(int x)


void ClearFile( )

ofstream out1;
out1.open("2.txt");
out1.close( );

int main( )

ClearFile( );
fun(100);
return 0;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请补充完整程序fun(int i),使其完成以下功能:如果i=5,则输出如下5行井号。
#
##
###
####
#####
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<iostream.h>
void fun(int i)


int main( )
fun(5);
return 0;

[简答题]使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(int x),该函数的功能是将x的值转换成二进制数输出到屏幕,并且在函数中调用写函数WriteFile将结果输出到2.txt文件中。
例如x=6,6的二进制数为110,则输出到屏幕的数为110。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<iostream>
#include<fstream>
#include<cmath>
using namespace std;
void WriteFile(char *str)

ofstream out1;
out1.open("2.txt",ios_base::binary|ios_base::app);
for(int i=0;str[i]!=0;i++)
out1.put(str[i]);
out1.close( );

void fun(int x)


void ClearFile( )

ofstream out1;
out1.open("2.txt");
out1.close( );

int main( )

ClearFile( ):
fun(13);
return 0;

[简答题]将考生文件夹下MYTAXI文件夹中的文件夹HIPHI移动到考生文件夹下COUNT文件夹中。

我来回答:

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

订单号:

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