C++大作業(yè)報(bào)告_第1頁
C++大作業(yè)報(bào)告_第2頁
C++大作業(yè)報(bào)告_第3頁
C++大作業(yè)報(bào)告_第4頁
C++大作業(yè)報(bào)告_第5頁
已閱讀5頁,還剩80頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上 C+大作業(yè)報(bào)告 班級 姓名 總學(xué)號 一題目:21內(nèi)容:用三種循環(huán)語句完成求100以內(nèi)的質(zhì)數(shù)設(shè)計(jì)思路:1既不是質(zhì)數(shù)也不是合數(shù),所以直接從2考慮。找出來這些數(shù)字就是要保證這個數(shù)只能讓1和其本身整除,所以讓這個數(shù)先除以2,然后慢慢整除其小于除以2后的數(shù),然后輸出這些數(shù)。 程序代碼:while 循環(huán)#include<iostream>using namespace std;int main()int i=2;int j,n,m;while (i<101)m=1;n=i/2;j=2;while (j<=n)if(i%j=0)m=0;break;j+;i

2、f(m)cout<<i<<endl;i+;return 0;Do while 循環(huán)#include<iostream>using namespace std;void main()int i=2;int j,n,m;dom=1;n=i/2;j=2;doif(i%j=0)m=0;break;j+;while(j<=n)if(m)cout<<i<<endl;i+while(i<101);return 0;For 循環(huán)#include<iostream>using namespace std;void main()i

3、nt i,j,n,m;for (i=2;i<101;i+)m=1;n=i/2;for (j=2;j<=n;j+)if (i%j=0)m=0;break;if (m)cout<<i<<endl;return 0;運(yùn)行結(jié)果:結(jié)論: 不管for還是while還是do while,他們的循環(huán)體都是一樣的,所以只要編出來一個就等于全編出來了,而且程序要設(shè)計(jì)盡量簡單。題目:22內(nèi)容:輸入一個有符號的十進(jìn)制數(shù),轉(zhuǎn)換成機(jī)內(nèi)二進(jìn)制數(shù)輸出(要求用位操作運(yùn)算)。設(shè)計(jì)思路:利用位運(yùn)算將二進(jìn)制的每一位取出存入數(shù)組,然后按要求輸出。程序代碼:#include <iostream&

4、gt;using namespace std;void main()char a;int t8;int i;cout<<"請輸入一個數(shù)y:n"cin>>a;for(i=0;i<8;i+)ti=a&0x01;a=a>>1;for(i=7;i>=0;i-)cout<<ti;cout<<endl;system("pause");結(jié)果: 結(jié)論:只有掌握位運(yùn)算規(guī)則,才能編出來程序二內(nèi)容: 書上P144,4-10 設(shè)計(jì)一個用于人事管理的“人員”類 .由于考慮到通用性,這里只抽象出所有人員

5、都具有的屬性:編號,性別,出生日期,身份證號.(“出生日期”聲明為一個“日期”類內(nèi)嵌子對象。用成員函數(shù)實(shí)現(xiàn)對人員信息的錄入和顯示。要求包括:構(gòu)造函數(shù)、復(fù)制構(gòu)造函數(shù)、內(nèi)聯(lián)成員函數(shù)、帶默認(rèn)形參值的成員函數(shù)、類的組合。)設(shè)計(jì)思路:通過構(gòu)造函數(shù),實(shí)現(xiàn)人員的錄入和輸出。程序代碼:#include<iostream>using namespace std;class dateprivate: int year; int month; int day;public: date(int a=0,int b=0,int c=0)year=a;month=b;day=c; inline void se

6、tyear(int y)year=y; void setmonth(int m) month=m; void setday(int d) day=d; void showdate() cout<<year<<" "<<month<<" "<<day<<" "<<endl; ;class peopleprivate: char number100; char id100; char sex2; date birthday; public: people(

7、); people(people&p); people(); void setnumber(char* a) strcpy(number,a); void setid(char*); void setsex(char* c) strcpy(sex,c); void setbirthday(date d) birthday=d; char *getnumber() return number; char *getsex() return sex; char *getid() return id; date getbirthday() return birthday; ;date d;ch

8、ar m;people:people():birthday(d)void people:setid (char*ids) strcpy(id,ids);int main() date birthday; cout<<"錄入信息"<<endl; people p1; /people*p4=&p1,&p2,&p3,&p4; cout<<"輸入員工的出生日期"<<endl; cout<<"年" int a; cin>>a; birthda

9、y.setyear (a); cout<<"月" int b; cin>>b; birthday.setmonth (b); cout<<"日" int c; cin>>c; birthday.setday (c); cout<<"輸入編號"<<endl; char numberstr20; cin>>numberstr; p1.setnumber (numberstr); cout<<"輸入身份證號"<<e

10、ndl; char idstr20; cin>>idstr; p1.setid (idstr); cout<<"輸入性別"<<endl; char sexstr30; cin>>sexstr; p1.setsex (sexstr); cout<<"輸出信息"<<endl; cout<<"員工的出生日期" birthday.showdate (); cout<<"編號為 "<<p1.getnumber() &l

11、t;<" 身份證號為 "<<p1.getid() <<"性別為 "<<p1.getsex() ; return 0;運(yùn)行結(jié)果:結(jié)論: 要充分理解函數(shù)的概念,只有在理解的情況下才能編出程序。但是不能實(shí)現(xiàn)多個成員的錄入和輸出。內(nèi)容: 書上P144,4-11定義并實(shí)現(xiàn)一個矩形類,有長、寬兩個屬性,由成員函數(shù)計(jì)算矩形的面積。設(shè)計(jì)思路:通過設(shè)計(jì)類,實(shí)現(xiàn)矩形的計(jì)算函數(shù)程序代碼:#include<iostream>using namespace std;class Rectanglepublic:Rectangle

12、(); float area(); void show();private:float a;float b;Rectangle:Rectangle() do cout<<"please input two numbers :"<<endl; cin>>a>>b;while(a<= 0 | b<= 0); float Rectangle:area()return a*b;void Rectangle:show()cout<<"a="<<a<<",b=&

13、quot;<<b<<",area="<<area()<<endl;int main()Rectangle c;c.show();return 0;運(yùn)行結(jié)果:結(jié)論: 要理解類的含義,理解每個定義的作用!三內(nèi)容:書上P186 5-7定義一個Cat類,擁有靜態(tài)數(shù)據(jù)成員numOfCats,記錄cat的個體數(shù)目,靜態(tài)成員函數(shù)getNumOfCats(),讀取numOfCats。設(shè)計(jì)程序測試這個類,體會靜態(tài)數(shù)據(jù)成員和靜態(tài)成員函數(shù)的用法!設(shè)計(jì)思路:定義一個cat類,通過構(gòu)造函數(shù),并且聲明靜態(tài)數(shù)據(jù)成員。代碼:#include <iost

14、ream>#include <string>using namespace std;class Catpublic: Cat()+numOfCats; Cat(const Cat& cat)+numOfCats; virtual Cat()-numOfCats; static int getNumOfCats()return numOfCats;private: static int numOfCats;int Cat:numOfCats=0;int main() Cat a; Cat b; cout<<"numOfCats:"<

15、<Cat:getNumOfCats()<<endl; Cat c(a); Cat* p=new Cat(); cout<<"numOfCats:"<<Cat:getNumOfCats()<<endl; delete p; cout<<"numOfCats:"<<Cat:getNumOfCats()<<endl; return 0;運(yùn)行結(jié)果:結(jié)論:這部分與類密切聯(lián)系,所以要掌握類,并且理解靜態(tài)數(shù)據(jù)成員的使用.內(nèi)容:書上P186 5-14定義Boat類和Car兩個類,二

16、者都有weight屬性,定義二者的友元函數(shù)getTotalWeight(),計(jì)算二者重量之和!設(shè)計(jì)思路:定義兩個類,使其為友元函數(shù),在其基礎(chǔ)上進(jìn)行所需的運(yùn)算。代碼:#include<iostream>using namespace std;class Car;class Boatprivate: int Boatweight;public: Boat() Boatweight=450; friend int totalWeight(Boat &,Car &);class Carprivate: int Carweight;public: Car( ) Carweig

17、ht=450; friend int totalWeight(Boat &,Car &);int totalWeight(Boat &x,Car &y) return x.Boatweight+y.Carweight;int main() Boat a; Car b; cout<<"這兩者的總重量為"<<totalWeight(a,b)<<endl; return 0;運(yùn)行結(jié)果: 結(jié)論:在理解類的情況下,可以用友元函數(shù)。在編寫程序時(shí),可以有效的減少程序的冗長。四內(nèi)容:書上P248 已知有一個數(shù)組名叫oneA

18、rray,用一條語句求出其元素的個數(shù)。 設(shè)計(jì)思路:利用sizeof函數(shù)代碼:#include <iostream>using namespace std;int main() int array = 8, 4, 3, 4, 5,7,9,10; int i = sizeof(array)/sizeof(int); cout << i << endl; return 0;結(jié)果:結(jié)論:掌握基本函數(shù)的含義和用法內(nèi)容:書上P249 6-20實(shí)現(xiàn)一個名為SimpleCircle的簡單圓類。其數(shù)據(jù)成員int*itsRadius為一個指向其半徑的指針,存放其半徑值。設(shè)計(jì)數(shù)據(jù)

19、成員的各種操作,給出這個類的完整實(shí)現(xiàn)并測試這個類。設(shè)計(jì)思路:利用類與友元函數(shù)代碼:#include <iostream> using namespace std;class SimpleCirclepublic:SimpleCircle();SimpleCircle(int);SimpleCircle(const SimpleCircle &);SimpleCircle() void SetRadius(int);int GetRadius()const; private:int *itsRadius; SimpleCircle:SimpleCircle()itsRadiu

20、s = new int(5); SimpleCircle:SimpleCircle(int radius)itsRadius = new int(radius); SimpleCircle:SimpleCircle(const SimpleCircle & rhs)int val = rhs.GetRadius();itsRadius = new int(val); int SimpleCircle:GetRadius() constreturn *itsRadius;int main()SimpleCircle CircleOne, CircleTwo(9);cout <<

21、; "CircleOne: " << CircleOne.GetRadius() << endl;cout << "CircleTwo: " << CircleTwo.GetRadius() << endl;return 0;結(jié)果:結(jié)論:要充分理解類的含義與用法,理解友元的用法 五內(nèi)容:書上P250 6-22編寫函數(shù)void reverse(string &s),用遞歸算法是字符串倒置。算法設(shè)計(jì):利用遞歸算法設(shè)計(jì)倒敘代碼:#include<iostream>#include&

22、lt;string>using namespace std;void reverse (char *s)char t;static int i=0;t = *(s+strlen(s)-i-1);*(s+strlen(s)-i-1) = *(s+i);*(s+i) = t;i+;if(strlen(s)/2=i);else reverse (s);void main()char s100;cout<<"請輸入字符串:"<<endl;cin>>s;reverse(s);cout<<"倒序后的字符串:"&l

23、t;<endl;cout<<s<<endl;結(jié)果: 結(jié)論:要熟練掌握遞歸方法內(nèi)容:書上P250 6-27定義一個Employee類,其中包括姓名、地址、城市和郵編等屬性,包括setname(),display(),等函數(shù)。Display()使用cout語句顯示姓名、地址、城市和郵編等屬性,函數(shù)setname()改變對象的姓名屬性,實(shí)現(xiàn)并測試這個類。算法設(shè)計(jì):利用類來設(shè)計(jì)這個程序代碼:#include <iostream>using namespace std;class Employee private: char *name,*address,*ci

24、ty,*postCode;public: Employee(char *_name,char *_address,char *_city,char *_postCode) name = _name; address = _address; city = _city; postCode = _postCode; void setName(char *_name) name = _name; void display() cout<<"name : "<<name<<endl; cout<<"address : &quo

25、t;<<address<<endl; cout<<"city : "<<city<<endl; cout<<"postcode : "<<postCode<<endl; ;int main(int argc,char *argv) Employee *e =new Employee("張三","天堂","宇宙",""); e->display(); e->setName

26、("李四"); e->display(); 結(jié)果:結(jié)論:熟練掌握類的方法,用類來表示需要表示的東西。 六題目:定義一個基類sharp,在此基礎(chǔ)上派生出rectangle和circle,兩者都有g(shù)etarea()函數(shù)計(jì)算面積。程序代碼:#include <iostream>#include <cmath>#define pi 3.14using namespace std;class shape public: virtual float area()=0;class circle:public shape public: circle(floa

27、t r1) r=r1; private: float r; float area() return (float)pi*r*r; ;class rectangle:public shape public: rectangle(float w1,float h1) width=w1;height=h1; private: float width,height; float area() return width*height; ;class square : public rectangle public: square(float len):rectangle(len,len); square

28、(); float area(float len) return len * len; ;int main() shape* s2; int m,a,b; cout<<"輸入圓半徑:"<<endl; cin>>m; s0=new circle(m); cout<<s0->area()<<endl; cout<<"輸入長和寬:"<<endl; cin>>a>>b; s1=new rectangle(a,b); cout<<s1-&g

29、t;area()<<endl; s 2 = new square( a ); cout << s2->area() << endl; return 0;:運(yùn)行結(jié)果:結(jié)論:在派生類的基礎(chǔ)上在派生,相當(dāng)于把派生看作是基類!題目:定義一個Document類,有數(shù)據(jù)成員name,從document派生出book類,增加數(shù)據(jù)pagecount。程序代碼:#include<iostream>#include<string>using namespace std;class Document public:Document(string Na

30、me) name=Name;void display() /cout<<"name="<<name<<endl;private:string name; ;class Book:public Document public:Book(string nam,int page):Document(nam) pageCount=page; void show() /顯示Book類數(shù)據(jù)的函數(shù)cout<<"pageCount="<<pageCount<<endl;private:int pag

31、eCount; /該類有數(shù)據(jù)成員pageCount;int main() Book a("李四",50); a.display(); /顯示數(shù)據(jù)name a.show(); /顯示數(shù)據(jù)pageCountreturn 0;運(yùn)行結(jié)果:結(jié)論:掌握類的含義,在類的基礎(chǔ)上派生,直接輸出的!可以轉(zhuǎn)換為輸入輸出!七題目:7-10一、內(nèi)容:定義一個object類,有數(shù)據(jù)成員weight及相應(yīng)的操作函數(shù),由此派生出box類,增加數(shù)據(jù)成員height和width及相應(yīng)的操作函數(shù),聲明一個box類對象,觀察構(gòu)造函數(shù)和析構(gòu)函數(shù)的調(diào)用順序。二、設(shè)計(jì)思路:利用類的派生思想三、程序代碼:#include

32、<iostream>using namespace std;class Objectpublic:Object()cout<<"call the Object's constructor"<<endl;void set_weight(int neww=0,int newn=0)weight=neww;num=newn;void total_weight()cout<<"the total weight is"<<" "<<weight*num<<

33、;endl;int getw()return weight;Object()cout<<"call the Object's desconstructor"<<endl;private:int weight,num;class Box:public Objectpublic:Box() cout<<"call the Box's constructor"<<endl;void set_digital(int h=0,int w=0,int l=0)height=h;width=w;lengt

34、h=l;void showBox()cout<<"Box's height:"<<height<<endl;cout<<"Box's width:"<<width<<endl; cout<<"Box's length:"<<length<<endl;cout<<"box's weight"<<getw()<<endl;Box()cout<

35、;<"call the Box's desconstructor"<<endl;private:int height,width,length;void main()Box a;a.set_weight(4,5);a.total_weight();a.set_digital(1,2,3);a.showBox();四、運(yùn)行結(jié)果:題目:711一、內(nèi)容:定義一個基類baseclass,從它派生出類derivedclass。Baseclass有成員函數(shù)fn1,fn2,derivedclass也有成員函數(shù)fn1,fn2。在主函數(shù)中聲明一個derivedcla

36、ss的對象,分別用derivedclass的對象以及baseclass和derivedclass的指針來調(diào)用fn1,fn2,觀察運(yùn)行結(jié)果。 程序代碼:#include<iostream>using namespace std;class BaseClasspublic:void fun1()cout<<"1"<<endl;void fun2()cout<<"2"<<endl;class DerivedClass:public BaseClasspublic:void fun1()cout<

37、<"3"<<endl;void fun2()cout<<"4"<<endl;void main()DerivedClass a;cout<<"通過DerivedClass的對象調(diào)用函數(shù)"<<endl;a.BaseClass:fun1(); a.BaseClass:fun2(); a.fun1(); a.fun2(); BaseClass &b=a; cout<<"通過BaseClass的指針調(diào)用函數(shù)"<<endl; b

38、.fun1(); b.fun2(); DerivedClass &t=a; cout<<"通過DerivedClass的指針調(diào)用函數(shù)"<<endl; t.BaseClass:fun1(); t.BaseClass:fun2(); t.fun1(); t.fun2();運(yùn)行結(jié)果: 八一、內(nèi)容:使用I/O流以文本方式建立一個文件test1.txt,寫入字符“已成功寫入文件!”用其他字處理程序(例如windows的記事本程序Nodepad)打開,看看是否正確寫入。使用I/O流以文本方式打開11-3題建立的文本text1.txt讀出其內(nèi)容并顯示出來,

39、看看是否正確。二、設(shè)計(jì)思路:利用輸出流對象ofstream和輸入流對象ifstream實(shí)現(xiàn)對文件的操作。代碼:#include<iostream>#include <fstream>#include <string>using namespace std;void main() ofstream ofile("test1.txt"); string s="已成功寫入文件"cout<<s<<" "<<s.length(); ofile.write(char*)&am

40、p;s,s.length(); ofile.close(); ifstream tfile("test1.txt");cout<<"ndispaly filen"string s2; if(tfile) tfile.read(char*)&s2,s.length(); cout << s2<<endl; else cout << "ERROR: Cannot open file 'payroll'." << endl; tfile.close();結(jié)果

41、: 題目11-6一、內(nèi)容:定義一個dog類,包涵體重和年齡兩個成員函數(shù),聲明一個實(shí)例dog1,體重為5,年齡為10,使用I/O流把dog1的狀態(tài)寫入磁盤文件,再聲明另一個dog2,通過讀文件把dog1的狀態(tài)賦給dog2。使用二進(jìn)制方式操作文件,看看結(jié)果有何不同;再看看磁盤文件的ASCII碼有何不同。二、設(shè)計(jì)思路:三、程序代碼:#include<iostream>#include <fstream>using namespace std;class dogpublic:dog(int weight, long days):itsWeight(weight),itsNumb

42、erDaysAlive(days)dog()int GetWeight()const return itsWeight; void SetWeight(int weight) itsWeight = weight; long GetDaysAlive()const return itsNumberDaysAlive; void SetDaysAlive(long days) itsNumberDaysAlive = days; private:int itsWeight;long itsNumberDaysAlive;int main() / returns 1 on errorchar fi

43、leName80;cout << "Please enter the file name: "cin >> fileName;ofstream fout(fileName);/ ofstream fout(fileName,ios:binary);if (!fout)cout << "Unable to open " << fileName << " for writing.n"return(1);dog Dog1(5,10);fout.write(char*) &D

44、og1,sizeof Dog1);fout.close();ifstream fin(fileName);/ ifstream fin(fileName,ios:binary);if (!fin)cout << "Unable to open " << fileName << " for reading.n"return(1);dog Dog2(2,2);cout << "Dog2 weight: " << Dog2.GetWeight() << endl;cou

45、t << "Dog2 days: " << Dog2.GetDaysAlive() << endl;fin.read(char*) &Dog2, sizeof Dog2);cout << "Dog2 weight: " << Dog2.GetWeight() << endl;cout << "Dog2 days: " << Dog2.GetDaysAlive() << endl;fin.close();return 0;

46、四、運(yùn)行結(jié)果:九內(nèi)容: 分別用函數(shù)重載,函數(shù)的缺省參數(shù)及模板函數(shù)完成兩個或三個(n個)數(shù)相加。設(shè)計(jì)思路:定義不同的函數(shù)讓兩個數(shù)相加,然后讓其根據(jù)數(shù)據(jù)類型相加。 設(shè)計(jì)相加的函數(shù),然后用主函數(shù)調(diào)用函數(shù),運(yùn)行結(jié)果。程序代碼:函數(shù)重載:#include<iostream>using namespace std;int sum(int m,int n)return m+n;double sum(double m,double n)return m+n;int main()int m,n;cout<<"Enter two numbers:"cin>>

47、m>>n;cout<<"Their sum:"<<sum(m,n)<<endl;double x,y;cout<<"Enter two other numbers:"cin>>x>>y;cout<<"Their sum:"<<sum(x,y)<<endl;return 0;缺省參數(shù):#include<iostream>using namespace std;int Sum(int a,int b=5,in

48、t c=2) return a+b+c;int main()const x=8,y=1,z=9;cout<<Sum(x,y,z)<<endl;cout<<Sum(x,y)<<endl;cout<<Sum(x)<<endl;return 0;函數(shù)模板:#include<iostream>using namespace std;int Sum(int a,int b/*=4*/,int c/*=8*/)return a+b+c;template<class T>T sum(T x,T y)return

49、x+y;int main()int a=4,b=9;double c=3.4,d=2.6;cout<<"Their sum:"<<sum(a,b)<<endl;cout<<"Their sum:"<<sum(c,d)<<endl;return 0;運(yùn)行結(jié)果:結(jié)果一:結(jié)果二:結(jié)果三:結(jié)論:個人覺得使用函數(shù)重載比較好,因?yàn)槠湟酌靼祝?容易操作。 十內(nèi)容:用類完成一個時(shí)鐘,要求做到使用構(gòu)造函數(shù) 使用析構(gòu)函數(shù) 十二時(shí)制,二十四時(shí)制 顯示時(shí)間 輸入走過的時(shí)間,在輸出走過之后顯示的時(shí)間設(shè)計(jì)思路:

50、設(shè)置時(shí)鐘,構(gòu)造函數(shù),通過數(shù)字大小判定是否是AM還是PM,看分,秒是否大于60,注意加一。代碼:#include<iostream>using namespace std;class Clockpublic:Clock(int newH,int newM,int newS);Clock(Clock &a);void setTime(int newH,int newM,int newS);void showTime();void run(int newH,int newM,int newS,int k);private:int hour,minute,second;Clock:

51、Clock(int newH,int newM,int newS)hour=newH;minute=newM;second=newS;void Clock:setTime(int newH,int newM,int newS)hour=newH;minute=newM;second=newS;inline void Clock:showTime()if(hour>=12)&&(hour<=23)cout<<"PM"<<hour-12<<":"<<minute<<&qu

52、ot;:"<<second<<endl; else if(hour>=0)|(hour<12)cout<<"AM"<<hour<<":"<<minute<<":"<<second<<endl;void Clock:run(int newH,int newM,int newS,int k) newS=newS+k;if(newS>60) second=newS-60;newM=newM+1;else s

53、econd=newS;if(newM>60) minute=newM-60;newH=newH+1;else minute=newM;int main() int h,m,s,k;cout<<"please enter time:"<<endl;cout<<"h"<<" ""m"<<" ""s"<<endl;cin>>h>>m>>s;cout<<&qu

54、ot;k"<<endl;cin>>k;Clock a(0,0,0);a.showTime(); a.setTime(h,m,s);a.showTime();a.run(h,m,s,k);a.showTime();return 0;運(yùn)行結(jié)果:結(jié)論:時(shí)鐘函數(shù)需要自己掌握構(gòu)造,調(diào)用函數(shù)等,要認(rèn)真,不放棄,就會編出自己的程序十一內(nèi)容: 求解一元二次方程設(shè)計(jì)思路:通過類來設(shè)計(jì)程序。 程序代碼: #include<iostream>#include<math.h>using namespace std;class funtionpublic: vo

55、id make();void display(); void answer();private: float a,b,c;float x1,x2; float r,i,f;void funtion:make () cout<<"輸入 a b c 的值"<<endl; cin>>a; cin>>b; cin>>c;void funtion:display ()f=b*b-4*a*c; if(f>0) x1=-b/(2*a)+sqrt(f)/(2*a); x2=-b/(2*a)-sqrt(f)/(2*a); el

56、se if(f=0) x1=-b/(2*a); x2=-b/(2*a); else r=-b/(2*a); i=sqrt(-f)/(2*a); void funtion:answer() if(f>0) cout<<"x1="<<x1<<" "<<"x2="<<x2<<endl; else if(f=0) cout<<"x1="<<x1<<" "<<"x2=&q

57、uot;<<x2<<endl; else cout<<"x1="<<r<<'+'<<i<<"i"<<" "<<"x2="<<r<<'+'<<i<<"i"<<endl;int main() funtion c; c.make (); c.display (); c.answer (); return 0;運(yùn)行結(jié)果:結(jié)論:類需要靈活使用,明白面對對象和面對過程的區(qū)別! 十二內(nèi)容:書上P222修改算法設(shè)計(jì):通過書上的描述,加上一些自己的理解代碼:#include<iostream>#include<

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論