更多"用VC++6.0打开考生文件夹下的源程序文件3.cpp,这个工程完成输"的相关试题:
[填空题]用VC++6.0打开考生文件夹下的源程序文件3.cpp,这个工程完成输出到屏幕一些特定的信息,但工程有错误或者不完整,请完成以下功能:
(1)初始化Num2的值为j,请在注释1后添加适当的语句。
(2)补充全局函数fun使之能够调用类TC的成员变量,请在注释2后添加适当的语句。
(3)初始化静态变量,请在注释3后添加适当的语句。
(4)修改注释4后的语句。使得程序输出以下内容:
Num1=7
Num2=12
Num3=-7
Num1=6
Num2=9
Num3=-17
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
试题程序:
#include<iostream.h>
class TC
public:
//********1********
TC(int i,int j)
Num1=i;
Num3=-i;
void Print( )
cout<<"Num1="<<Num1<<end1;
cout<<"Num2="<<Num2<<end1;
cout<<"Num3="<<Num3<<end1;
void Add(int i)
Num3-=i;
private:
int Num1;
const int Num2;
static int Num3;
//********2********
;
//********3********
void fun( )
TC obj(5,9);
obj.Num1=6;
//********4********
obj.Add( );
obj.Print( );
void main( )
TC obj(7,12);
obj.Print( );
fun( );
return;
[简答题]将考生文件夹下SHOP/DOCTER文件夹中的文件IRISH复制到考生文件夹下文件夹下的SWISS文件夹中,并将文件夹更名为SOUETH。
[简答题]将考生文件夹下BUG/XU文件夹复制到考生文件夹下DUP文件夹中。
[简答题]将考生文件夹下BEN/TOOL文件夹中的BAG文件夹复制到考生文件夹下。
[简答题]使用VC6打开考生文件夹下的工程RevProj10。此工程包含一个源程序文件RevMain10.cpp。在该文件中,函数fun的功能是:计算出数组x中的最小值与次最小值,并分别将其与x[0]、x[1]交换。
请改正程序中的错误,使它能得到正确结果。
注意,不要改动主函数,不得删行或增行,也不得更改程序的结构。
源程序文件RevMain10.cpp中的程序清单如下:
//RevMain10.cpp
#include <iostream>
using namespace std;
#define N 30
int fun(int *x, int n);
int main ( )
int h[N]=4,7, 6, 5, 1, 7,3, 8,0,2,3;
int i;
for (i=0; i<11; i++)
cout<<h [i] << " " ;
cout <<"/n";
fun(h, 11);
for (i=0; i<n; i++)
cout<<h [i]<<" ";
cout<<’ /n’;
return 0;
int fun(int *x, int n)
int i,t;
int a1=0, a2=0,min1=32767,min2=32676;
/* * * * *FOUND * * * * */
for(i=1;i<n;i++)
if (x [i]<min1)
min2=min1;
a2=a1;
min1=x [i];
a1=i;
else if (x [i] <min2)
[简答题]使用VC6打开考生文件夹下的工程RevProj8。此工程包含一个源程序文件 RevMain8.cpp。在该文件中,函数resort的功能是:能在一个数列中,对从指定位置开始的几位数,按相反顺序重新排列,并在主函数中输出新的序列。
请改正程序中的错误,使它能得到正确结果。
注意,不要改动main函数,不得删行或增行,也不得更改程序的结构。
源程序文件RevMain8.cpp中的程序清单如下:
//RevMain8.cpp
#include <instream>
using namespace std;
void resort(int arr[],int where,int amount);
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<<"/n where do you want to start: ";
cin>>where;
cout<<"old array as follow:/n";
for (i=0; i<20; i++)
cout<<nmuber [i] <<" ";
resort (number,where, arrount);
cout<<"/n resorted array as follow:/n";
for (i=0; i<20; i++)
cout<<number [i] <<" ";
cout<<end1;
return 0;
void resort(int array[],in
[简答题]使用VC6打开考生文件夹下的工程RevPrroj7。此工程包含一个源程序文件 RevMain7.cpp。在该文件中,函数fun( )的功能是:逐个比较a、b两个字符串对应位置中的字符,把ASCII码值大或相等的字符依次存放到c数组中,形成一个新的字符串。例如:若a中的字符串为aBCDeFgH,b中的字符串为ABcd,则c中的字符串为 aBcdeFgH。
请改正程序中的错误,使它能得到正确结果。
注意,不要改动主函数,不得删行或增行,也不得更改程序的结构。
源程序文件RevMain7.cpp中的程序清单如下:
//RevMain7.cpp
#include<iostream>
#include<string>
using namespace std;
void fun(char *p,char *q,char *c)
int k=1;
while(*p!=*q)
if(*p<*q)
c[k]=*q;
else
c[k]=*p;
if(*p)
p++;
if(*q)
q++;
int main( )
char a[10]="aBCDeFgH",b[10]="ABcd",c[80]=’/0’;
fun(a,b,c);
cout<<"The string a is "<<a<<’/n’;
cout<<"The string b is "<<b<<’/n’;
cout<<"The string c is "<<c<<endl;
return 0;