问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为:Hello注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。#include<iostream.h>void main(){//********error********typedef BOOL bool;//********error********BOOL a=FALSE;int i=0X80000000;//********error********a=!i;if(a){cout<<"Hello"<<endl;}return;}
问答题请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2,此工程包含程序文件main.cpp,其中有类Graphics(“图形”)、Squares(“正方形”)、Diamods(“菱形”)的定义和主函数main的定义。请在程序中的横线处填写适当的代码,然后删除横线,以实现上述定义。例如,当输入数值3时,程序分别输出边长为3的菱形和正方形,即此程序的正确输出结果应为:**********************注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动”//**********found**********#inflnclude<10stream>#include<iomanip>using namespace std;class Graphics//图形类{public: Graphics(int e):edges(e){) //**********found********** ——;protected:int edges;};class Squares:public Graphics//正方形类{public: Squares(int x):Graphics(x){) void Draw();},void Squares::Draw(){int i,j;if(edges<=0)cout<<“errors”<<endl; if(edges>0) {for(i=0;i<edges ; i++){for(j=0;j<edges;j++)cout<<setw(2)<<‘*’;cout<<endl;}}}//**********found**********//菱形类 { public: Diamonds(int X):Graphics(x){)void Draw();};void Diamonds::Draw(){int i,j;if(edges<=0)cout<<“errors”<<endl;if(edges>0){for(i=0;i<edges;i++) //输出菱形的上半部分{cout<<setw(edges—i),//**********found**********cout<<‘*’;cout<<endl;}//**********found********** //输出菱形的下半部分{cout<<setw(edges—i+1),for(j=0;j<=2*(i一1);j++)cout<<‘*’;cout<<end1;} }}int main(){int e;cout<<"请输入表示边长的整数:;cin>>e;Graphics*objs[2];objS[0]=new Diamonds(e);objS[1]=new Squares(e);for(int i=0;i<2;i++’)obJ S[i]一>Draw();delete objS[0];delete,jobjS[1],return 0;}
问答题使用VC6打开下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)重载运算符int,请在注释//********1********后添加适当的语句。(2)重载运算符“”,请在注释//********2********后添加适当的语句。(3)在主函数main()中定义变量i,并调用对象obj的int运算符,给变量赋初值为10,请在注释//********3********后添加适当的语句。(4)调用obj的“”运算符输出:HelloTest注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream>usingnamespacestd;classTestClass{public://********1********{cout"int"endl;return10;}//********2********coutstrendl;}};intmain(){TestClassobj;//********3********//********4********return0;}
问答题请使用VC6或使用[答题]菜单打开考生文件夹prog3下的工程prog3,其中包含了类TaxCalculator(“个税计算器”)和主函数main的定义。创建“个税计算器”需要接收税率表信息和起征额信息。在main函数中,通过两个数组创建了如下的税率表:
下标
适用收入段下限(lower_limits)
适用税率(rates)
说明:适用的收入段为
0
0
5
大于0小于等于500
1
500
10
大于500小于等于2000
2
2000
15
大于2000小于等于5000
3
5000
20
大于5000小于等于20000
4
20000
25
大于20000小于等于40000
5
40000
30
大于40000小于等于60000
6
60000
35
大于60000小于等于80000
7
80000
40
大于80000小于等于100000
8
100000
45
大于100000
利用这个税率表创建“个税计算器”时,假定起征额为2000元(即不超过2000元的所得不征收个人所得税)。请补充完成计算应纳个人所得税额的成员函数getTaxPayable,其中的参数income为月收入。此程序的正确输出结果应为:
月收入为800元时应缴纳个人所得税0元 月收入为1800元时应缴纳个人所得税0元
月收入为2800元时应缴纳个人所得税55元 月收入为3800元时应缴纳个人所得税155元
月收入为4800元时应缴纳个人所得税295元
月收入为5800元时应缴纳个人所得税455元
注意:只能在函数getTaxPayable中的“//********333********”和“//********666********”之间填入若干语句,不要改动程序中的其他内容。
//TaxCalculator.h #include<iostream>
#include<iomanip> using namespace std;
class TaxCalculator{ public:
TaxCalculator (double the_limits[], double the_rates [], int the_length,
double the threshold) : lower_limits (new double
[the_length]), rates ( new double [the_length]), list_fen
(the_length), thresh-old (the_threshold) { for(int i=0;
i<list_len; i++) { lower_limits[i] = the_limits[i];
rates[i]=the_rates[i]; } }
~TaxCalculator() { delete [] lower_limits; delete [] rates; }
double getTaxPayable (double income) const; //返回指定月收入的应纳个人所得税额
void showTaxPayable (double income)const;
//显示指定月收入的应纳个人所得税额 private: double *
lower_limits; //适用收入段下限 double * rates; //适用税率
int list len; //税率表项数 double
threshold; //起征额 }; void
writeToFile(const char * path); //TaxCalcnlator.cpp
#include "TaxCalculator.h" double
TaxCalculator::getTaxPayable (double income)const{
double taxable =income-threshold;//应纳税工资额 double
tax_payable = 0.0; //应纳个人所得税额 int i=list_len-1;
while (i>=0) { //******** 333********
//******** 666******** --i;
} return tax_payable; }
void TaxCalculator:: showTaxPayable (double income)
const { cout <<"月收入为" <<setw (6) <<income <<"元时应缴纳个人所得科名"
<<setw (4)<<getTaxPayable (income) <<"元" <<endl;
} //main. cpp #include "TaxCal
culator, h" int main () { double limits [] =
{ 0.0, 500.0,2000.0, 5000.0, 20000.0, 40000.0,60000.0, 80000.0, 100000.0};
double rates[] = { 0.05, 0.1, 0.15,0.2, 0.25, 0.3, 0.35, 0.4,
0.45}; TaxCalculator calc (limits, rates,9, 2000.0);
calc.showTaxPayable (800.0);
calc.showTaxPayable(1800.0); calc.showTaxPayable(2800.0);
calc.showTaxPayable(3800.0);
calc.showTaxPayable(4800.0); calc.showTaxPayable(5800.0);
writeToFile (""); return 0;
}
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.epp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: Constructor called. The value is 10 Copy constructor called. The value is 10 Destructor called. Destructor called. 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 //proj1.cpp #include<iostream> using namespace std; class MyClass{ public: //ERROR**********found********** MyClass(int i) {value=i;tout<<"Constructor called."<<endl;} //ERROR**********found********** MyClass(const MyClass p) { value=p.value; cout<<"Copy constructor called."<<endl: } void Print() {cout<<"The value is" <<value<<endl;} //ERROR **********found********** void~MyClass() {cout<<"Destructor called."<<endl;} private: int value; }; int main() { MyClass obj1; objl.Print(); MyClass obj2(objl); obj2.Print(); return 0; }
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为:
TestClass1
TestClass2
注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在∥********error********的下面。
#include
#include
Struct TestClass0
{
∥********error********
virtual.void fun();
};
class TestClass1:public
TestClass0
{
void fun()
{
toutfun();
∥********error********
P=*obj 2;
P一>fun();
return;
}
问答题请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程proj1,该工程中包含程序文件main.epp,其中有类Foo和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: X=a Y=42 注意:只修改每个“//ERROR**********found**********”下的那一行,不要改动程序中的其他内容。#include<iostream>using namespace st;d;class Foo{public: Foo(char x){x =x;) char getX()const{return xj}public: static int Y;private: char x_;};//ERROR*********found*********int Foo.y_=42;int main(int argo,char*argv[]){//ERROR********* found********* Foo f;//ERROR*********found********* cout<<”X=”<<f.x <<end1; cout<<”Y=” <<f.y_<<endl; return 0;}
问答题请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,此工程中含有一个源程序文件projl.cpp。其中位于每个注释“//ERROR****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: Constructor called. The value is 10 Max number is 20 Destructor called. 注意:只能修改注释“//ERROR****found****”的下一行语句,不要改动程序中的其他内容。//projl.cpp#include<iostream>USing namespace std;class MyClass{public://ERROR**********found************* void MyClass(int i) {value=i;cout<<”Constructorcalled.”<<endl;} int Max(int X,int Y){return x>Y?x:y;)//求两个整数的最大值//ERROR**********found********** in=Max(int x,int Y, nt Z=0)//求三个整数的最大值 { if(x>y) return X>Z?x:Z; else return y>Z?Y:z; } int GetValue()const{return value;} 一MyClass(){cout<<”Destructorcalled.”<<endl;)Frivate: int value; }; int main() { MyClass obj(10);//ERROR**********found*********** cout<<”The value is”<<value()<<endl; cout<<”Max number is”<<obj.Max(10,20)<<endl; return 0; }
问答题a. show( );
问答题综合应用题
使用VC6打开考生文件夹下的工程test3_3,此工程包含一个源程序文件test3_3.cpp,其中建立了普通的基类base用于存储边的信息,建立派生类triangle和square,用于存储三角形和正方形的信息。请按要求完成下列操作,将类定义补充完整。
(1)定义基类base的保护数据成员x和y用于记录边的长度,它们都是int型的数据。请在注释"//**1**"之后添加适当的语句。
(2)完成基类base默认构造函数的定义,把数据成员x和y分别初始化为参数a和b的值,要求使用作用域符"::"。请在注释"//**2**"之后添加适当的语句。
(3)完成派生类triangle函数disp的定义,使其以"三角形面积:"的格式将三角形的面积输出到屏幕上。请在注释"//**3**"之后添加适当的语句。
(4)添写派生类square的默认构造函数的定义,使其调用基类的构造函数,记录下正方形的边长信息a,其缺省值为0。请在注释"//**4**"之后添加适当的语句。
输出结果如下:
三角形面积:200
正方形面积:400
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
源程序文件test3_3.cpp清单如下:
#include
class base
{
protected:
//**1**
public:
base(int a,int b)
{
//**2**
}
virtual void disp(){coutdisp();
p=
p->disp();
}
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成列操作,将类的定义补充完整,实现以下功能: (1)完成CBook类构造函数,对整型变量ID和作者Author进行赋值,请在注释//********1********后添加适当的语句。 (2)完成类CBooks的析构函数,释放申请的内存,请在注释//********2********后添加适当的语句。 (3)完成类CBooks的AddBookMember函数,请在注释//********3********后添加适当的语句。 (4)完成CBooks类,用于由书的ID检索到作者的函数char*GetBookAuthor(int nID),请在注释//********4********后添加适当的语句。 (5)程序的输出结果为: Tom Harry 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>#include<Cstring>Class CBook{public: int ID; char Author[32];public: CBook(int ID Number,char*Author Name) { this->ID=ID Number; //********1******** }};clas s CBooks{private: Class Node { public: Node*next; CBook*book; }*m pBook; public: CBooks() { m pBook=NULL; } ~CBooks() { //********2******** while() { Node*p = mpBook->next; delete m pBook->book; delete m pBook; m-pBook=p; } } int AddBookMenber(intnID,char*Author) { Node*p=m_pBook; Node*q=NULL; //********3******** while() { if f nID==p->book->ID) { return 0; } q=p; p=p->next; } if(P==NULL) { P=new Node; P->next=NULL; P->book = newCBook(nID,Author); } if(q==NULL) { m pBook=p; } else { q->next=p; } return 1; } char*GetBookAuthor(int nID) { Node*p=m_pBook; //********4******** while() { if(P->book->ID==nID) { return p->book->Author; } p=p->next; } return 0; } }; int main() { CBooks booksl; books 1.AddBookMenber(1,"Tom"); books 1.AddBookMenber(3,"Lee"); books 1.AddBookMenber(4,"Lily"); books 1.AddBookMenber(5,"Harry"); cout<<books1.GetBookAUthor(1)<<endl; cout<<books1.GetBookAUthor(5)<<endl; return 0;}
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。该工程中包含程序文件main.cpp,其中有类CDate(“日期”)和主函数main的定义。程序中位于每个“//ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 原日期:2005—9—25 更新后的日期:2006—4—1 注意:只修改每个“//ERROR****found****”下的那一行.不要改动程序中的其他内容。#include<iostream>#include<CStdlib>USing namespace std;class CDate//日期类{//ERROR*********found*********protected: CDaLe(){); CDate(int d,int m,int y) {//ERROR*********found********* SefiDafie(int day=d,int month=m,int year=y); }; void Display()://显示日期 void SetDate(int day,int month,int year)//设置日期 {m_nDay=day;m_nNonfih=month;m_nYear=year;}private: int m_nDay;//日 int m nNonth;//月 int m nYear;//年},void CDate::Display()//显示日期{//ERROR*********found********* cout<<m_nDay<<”一”<<m—nNonth<<”一”<<m-nYear; cout<<endl;}int main(){ CDate d(2 5,9,2 0 05);//调用构造函数初始化日期 cout<<“原日期:”; d.Display(); d.SefiDate(1,4,2 0 0 6);//N用成员函数重新设置日期cout<<"更新后的日期:";d.Display();return 0;}
问答题使用VC6打开
下的源程序文件modi3.cpp,其中定义了用于表示雇员的Employee类,但类Employee的定义并不完整。请按要求完成下列操作,将类CEmployee的定义补充完成。
(1)定义私有数据成员name、street、city、zipcode和age分别用于表示姓名、街道、城市、邮编、年龄,除年龄是整型外其余都是char型的数据。请在注释//********1********之后添加适当的语句。
(2)完成默认构造函数CEmployee的定义,使其把参数传递给私有数据成员name、street、city、zipcode和age。请在注释//********2********之后添加适当的语句。
(3)完成成员函数alterName(char *newName)的定义。请在注释//********3********料料之后添加适当的语句。
(4)完成成员函数IsEqual(char *ename)的定义,实现当name相等时返回真,否则为假的功能,请在注释//********4********之后添加适当的语句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
#include <iostream.h>
#include <string.h>
#define MAXLEN 20
class CEmployee
{
private:
//********1********
int age;
public:
CEmployee (char *newName, char *newStreet,char *newCt, char *newZp, int newAge);
void alterName(char *newName);
void display();
bool IsEqual(char *ename);
};
CEmployee::CEmployee (char *newName,char *newStreet, char *newCt, char *newZp, int newAge)
{
//********2********
age=newAge;
}
voidCEmployee::alterName (char *newName)
{
//********3********
}
bool CEmployee::IsEqual (char *ename)
{
//********4********
}
void CEmployee::display ()
{
cout
name
" "
street
" ";
cout
city
" "
zipcode
" "
age
endl;
}
void main (void)
{
CEmployee employee[4]=
{
CEmployee("李伟","兴荣路213号", "兰州", "413412",21),
CEmployee("张星","南山街157号", "贵州", "534670",30),
CEmployee("赵曦","北大街108号", "深圳", 412440",43),
CEmployee("刘兰","南山街330号", "北", 670893",17),
};
for(int i=0;i<4;i++)
employee[i].display();
cout
"/n 修改"张星"的名字为"刘新"/n"
endl;
for (int j=0;j<4;j++)
{
if (employee [j].IsEqual("张星"))
{
employee[j].
alterName ("刘新");
employee[j].display();
break;
}
}
}
问答题请使用VC6或使用【答题】菜单打开考生文件夹oroj3下的工程proj3,其中声明了SortedList类,是一个用于表示有序数据表的类。其成员函数insert的功能是将一个数据插入到一个有序表中,使得该数据表仍然保持有序。请编写这个insert函数。程序的正确输出应为: 插入前: 1,2,4,5,7,8,10 插入6和3后: 1,2,3,4,5,6,7,8,10 要求: 补充编制的内容写在“//**********333**********”与“//**********666**********”之间。不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数wfiteToFfle已经编译为obj文件,并且在本程序中调用。//SortedList,h#include<iostream>using namespace std;class SortedList{//有序数据表类 int len; double*d;public: SortedList(int len,double data[]=NULL); 一SortedList(){delete[]d;) int length()const{return len;)//有序数据表长度(即元素的个数) double getElement(int i)cons t{return d[i];} void insert(double data); void show()const;//显示有序数据表};void writeToFile(char*,const Sort edLiSt&);//main.cpp#include”SortedList.h”SortedLiSt:: SortedList (int len,double data[]):len(len)( d=new double[len]; for(int k=0;k<len;k++) d[k]=(data==NULL?0.0:data[k]); for(int i=0;i<len一1;i++){ int m=i; for(int j=i;j<len;j++) if(d[j]<d[m])m=j; if(m>i){ double t=d[m]; d[m]=d[i]; d[i]=t; } }}void SortedList::insert(double data){//********333********//********666********}void SortedList::show()const{//显示有序数据表 for(int i=0;i<len一1;i++) cout<<d[i]<<”,”; cout<<d[1en—1]<<endl;}int main(){double S[]={5,8,1,2,10,4,7};SortedList list(7,S);cout<<“插入前:”<<endl;list.show();list.insert(6.0);liSt.insert(3.0);cout<<“插入6和3后:”<<endl;list.show();writeToFile(””,list);return 0;}
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成类Rect的构造函数,实现对变量left、right、top、bottom的初始化,缺省值都为0,请在注释//********1********后添加适当的语句。 (2)完成类Rectangle的构造函数,请在注释//********2********后添加适当的语句。 (3)完成计算矩形对角线长度函数Diagonal(),请在注释//********3********后添加适当的语句。 (4)完成计算周长函数Girth(),请在注释//********4********后添加适当的语句。 程序输出: 50 140 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>#include<cmath>class Rectangle{public: int left,right,top,bottom; //********1******** { left=1; right=r; top=t; bottom=b; } //********2******** { left=rc.1eft; right=rc.right; top=rc.top; bottom=rc.bottom; ) float Diagonal() {//********3******** return } int Girth() { //********4******** return }};int main(){ Rectangle rect(20,50,40,80); Rectangle rect2(rect); cout<<rect2.Diagonal()<<end1; cout<<rect2.Girth()<<end1; return 0;}
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(int i),实现以下功能:当i等于5时,则打印如下内容。
#
##
###
####
#####
注意:不能修改程序的其他部分,只能修改fun()函数。
#include
void fun(int n)
{
}
void main()
{
int n;
cout>n;
if(n<1)
{
cout<<"输入的行数必须大于
0"<
问答题请使用“答题”菜单或使用VC6打开考生文件夹proj3下的工程proj3,其中包含了类Polyno-mial(“多项式”)的定义。形如5x4+3.4x2-7x+2代数式称为多项式,其中的5为4次项系数,3.4为2次项系数,-7为1次项系数,2为0次项(常数项)系数。此例缺3次项,意味着3次项系数为0,即省略了0x3。在Polynomial中,多项式的各个系数存储在一个名为coef的数组中。例如对于上面的多项式,保存在coef[0]、coef[1]、…、coef[4]中的系数依次为:2.0、-7.0、3.4、0.0、5.0,也即对于i次项,其系数就保存在coef[i]中。作为成员函数重载的运算符“+”用于计算两个多项式的和,并返回作为计算结果的那个多项式。请补充完成文件Polynomial.cpp中重载运算符函数operator+的定义。此程序的正确输出结果应为: p1+p2的结果:7.3X^4+20.6X^3-41.2X^2-2.4X+5 p2+p3的结果:-2.3X^5+14.6X^4+12.8X^3+2.8X^2+0.2X+1 注意:只需要在operator+的//********333********和//********666********之间填入若干语句,不要改动程序中的其他内容。 //源程序 //主函数 #include"Polynomial.h" int main() double p1[]=5.0,3.5,-41.2,7.8, p2[]=0.0,-5.9,0.0,12.8,7.3, p3[]=1.0,6.1,2.8,0.0,7.3,-2.3; Polynomial poly1(p1, sizeof(p1)/sizeof(double)), poly2(p2, sizeof(p2) /sizeof(double)), poly3(p3, sizeof(p3) /sizeof(double)); cout<<"p1+p2的结果:"<<(polyl+poly2).tostring()<<endl; cout<<"p2+p3的结果:"<<(poly2+poly3).tostring()<<endl; // writeToFile("K://b10//61000102//"); return 0: //Polynomial.cpp函数 #include"Polynomial.h" #include <strstream> #include <cmath> const char*Polynomial::tostring() const//将多项式转换成用于输出的字符串 static char s[1000]; s[0]=0; strstream buf(s,1000); for(int i=num_of_terms-1;i>=0;i--) if(coef[i]==0.0) continue, //0系数项不输出 if(coef[i]<0.0) buf<<"-"; //负系数先输出"-" else if(strlen(s)==0) buf<<" "; else buf<<"+": buf<<fabs(coef[i]); if(i>0) buf<<"X": if(i>1)buf<<"^"<<i; buf<<ends: return buf.str(); Polynomial Polynomial:: operator+(const Polynomial &x) const double c[100]=0.0;//存放结果系数的数组,所有元素初始化为零。假定项数不会超过100 //下面的n为两个操作数中项数的较大者 int n=(num_of_terms>=x.num_of_terms? num_of_terms:x.num_of_terms); //将两个多项式的对应系数之和存放到数组c的对应单元中 //********333******** //********333******** while(n>1&&c[n-1]==0.0)n--;//去除无效的(系数为0的)最高次项 return Polynomial(c,n);
问答题请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程proj1,该工程中含有一个源程序文件proj1.epp。其中位于每个注释“//ERROR****found****”之后的一行语句有错误。请改正这些错误,使程序的输出结果为:12 3 4 5 6 7 8 9 10 注意:只能修改注释“//ERROR****found****”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#include<iostream>using namespace std;class MyClass{public: MyClass(int len) { array=new int[len]; arraySize=len; for(int i=0;i<arraySize;i++) array[i]=i+1; } 一MyClass() {//ERROR**********found********** delete array[i]; ) void Print()const { for(int i=0;i<arraySize;i++)//ERROR**********found********* cin<<array[i]<<”; Cout<<endl; }private: int*array; int arraySize; ); int main() { //ERROR**********found**********MyClass obj;obj.Print();return 0;}
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。完成函数fun(char*str,char*s)空出部分。函数fun(ehaur*str,chaur*s)的功能是:将在字符串str中下标为偶数位置上的字符,紧随其后重复出现一次,放在一个新串S中,S中字符按原字符串中字符的顺序排列。(注意0为偶数)
例如:当str中的字符串为:“abcdef”时,s中的字符串应为:“aaccee”。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
#include
void fun(char*str,char*S)
{
}
void main()
{
char str[100],s[100];
cout<<“P1ease enter stringstring:”<
问答题使用VC6打开考生文件夹下的源程序文件modi2.epp。阅读下列函数说明和代码,完成空出部分程序,使该程序输出倒9×9口诀。
程序分析:分行与列考虑,共9行9列,设置两个变量i和j,i控制行,j控制列。
程序运行结果如下:
1*9=9 2*9=18 3*9=27 4*9=36 5*9=45
6*9=54 7*9=
63 8*9=72 9*9=81
1*8=8 2*8=16 3*8=24 4*8=32 5*8=40
6*8=48 7*8=
56 8*8=64
1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=
42 7*7=49
1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36
1*5=5 2*5=10 3*5=15 4*5=20 5*5=25
1*4=4 2*4=8 3*4=12 4*4=16
1*3=3 2*3=6 3*3=9
1*2=2 2*2=4
1*1=1
注意:只能补充函数show(),请勿改动其他部分的内容。
#include
void show()
{
}
void main()
{
cout<<"9*9倒乘法口诀"<
