![VC++程序設(shè)計課內(nèi)實驗報告_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/15/6070ae55-e1d5-4489-bdce-2a5000aa1df4/6070ae55-e1d5-4489-bdce-2a5000aa1df41.gif)
![VC++程序設(shè)計課內(nèi)實驗報告_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/15/6070ae55-e1d5-4489-bdce-2a5000aa1df4/6070ae55-e1d5-4489-bdce-2a5000aa1df42.gif)
![VC++程序設(shè)計課內(nèi)實驗報告_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/15/6070ae55-e1d5-4489-bdce-2a5000aa1df4/6070ae55-e1d5-4489-bdce-2a5000aa1df43.gif)
![VC++程序設(shè)計課內(nèi)實驗報告_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/15/6070ae55-e1d5-4489-bdce-2a5000aa1df4/6070ae55-e1d5-4489-bdce-2a5000aa1df44.gif)
![VC++程序設(shè)計課內(nèi)實驗報告_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/15/6070ae55-e1d5-4489-bdce-2a5000aa1df4/6070ae55-e1d5-4489-bdce-2a5000aa1df45.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、實驗報課程名稱VC+程序設(shè)計專業(yè)班級電子0942電氣與信息學(xué)院和諧勤奮求是創(chuàng)新實驗教學(xué)考核和成績評定辦法課內(nèi)實驗考核成績,嚴格按照該課程教學(xué)大綱中明確規(guī)定的比重執(zhí)行。實驗成績不合格者,不能參 加課程考試,待補做合格后方能參加考試。單獨設(shè)立的實驗課考核按百分制評分,考核內(nèi)容應(yīng)包括基本理論、實驗原理和實驗。3)1)實驗考核內(nèi)容包括:1)實驗預(yù)習(xí);2)實驗過程(包括實驗操作、實驗記錄和實驗態(tài)度、表現(xiàn)); 實驗報告;權(quán)重分別為 0.2、0.4、 0.4;原則上根據(jù)上述三個方面進行綜合評定。學(xué)生未取得 和2)項成績時,第 3)項成績無效。實驗指導(dǎo)教師應(yīng)嚴格按照考核內(nèi)容分項給岀評定成績,并及時批改實驗報告
2、,給岀綜合成績,反饋 實驗中岀現(xiàn)的問題。實驗成績在教師手冊中有記載。-一一實驗?zāi)康亩?實驗儀器及設(shè)備實驗原理四.實驗步驟五.實驗記錄及原始記錄、.六.數(shù)據(jù)處理及結(jié)論七.實驗體會(可選項)注:1.為了節(jié)省紙張,保護2.3.實驗報告主要內(nèi)容,便于保管實驗報告,統(tǒng)一采用A4紙,實驗報告建議雙面打印(正文采用宋體五號字) 或手寫,右側(cè)裝訂。實驗題目實驗五構(gòu)造函數(shù)與析構(gòu)函數(shù)的編程實驗室電信機房實驗時間年 月日實驗類別驗證同組人數(shù)1實驗類別指驗證、演示、綜合、設(shè)計、創(chuàng)新(研究)、操作六種類型實驗。驗證性實驗:是指為了使學(xué)生鞏固課程基本理論知識而開設(shè)的強調(diào)演示和證明,注重實驗結(jié)果(事實、概念或 理論)的實驗
3、。4. 綜合性實驗:是指實驗內(nèi)容涉及本課程的綜合知識或本課程相關(guān)的課程知識的實驗。5. 設(shè)計性實驗:是指給定實驗?zāi)康?、要求和實驗條件,由學(xué)生自行設(shè)計實驗方案并加以實現(xiàn)的實驗。成績指導(dǎo)教師簽字:一、實驗?zāi)康? .進一步加深對類和對象的理解。2 .掌握類的構(gòu)造函數(shù)和析構(gòu)函數(shù)的概念、意義和使用方法。3.掌握重載構(gòu)造函數(shù)的含義和使用。4編寫一個較為復(fù)雜的類和對象的應(yīng)用程序。二、實驗內(nèi)容1 設(shè)計一個程序,定義一個矩形類,包括數(shù)據(jù)成員和函數(shù)成員。要求有構(gòu)造函數(shù)、析構(gòu)函數(shù),還有一個成 員函數(shù)area()用來計算并顯示矩形的面積,并編寫main函數(shù)進行測試。程序:# in clude<iostream.
4、h> # in clude<math.h> class Rect public:Rect(i nt l, i nt w);Recto; int Area(); private: int nLen gth; int nWidth;Rect:Rect(i nt l, i nt w) cout<<"executi ng con structor."<<e ndl; nLen gth=l;n Width=w;cout< <"nLen gth=" <<nLen gth<<e ndl<
5、; <"n Width=" <<n Width<<e ndl; Rect:Rectocout<<"executi ng con structor."<<e ndl;cout< <"nLen gth=" <<nLen gth<<e ndl< <"n Width=" <<n Width<<e ndl; int Rect:Area() i nt t;t=nLen gth* nWidth;retur
6、n t;int mai nO Rect A(3,4); cout<<"s="<<A.Area()<<e ndl;return 0;我"E:XDebufXvbfbf. exe*運行結(jié)果:execut in ST nLengt 11=3 nWidth=4 =12 executing nLength=3 nWidth=4 Press anyCOnstrULCtOK.constpuctop-.Key to continuedouble型記2 .重載構(gòu)造函數(shù)。修改上題,一種構(gòu)造函數(shù)用整型變量記錄矩形的長和寬,另一種構(gòu)造函數(shù)用 錄矩形的長和
7、寬,然后完成成員函數(shù)及主函數(shù)。程序:# in clude<iostream.h># in clude<math.h>class Rectp ublic:Rect(i nt l, int w);Rect(double u, double v);int Area();double Area(double u, double v);Rect();private:int nLen gth;int nWidth;double mLen gth; double mWidth;;Rect:Rect(i nt l, i nt w)cout<<"executi ng
8、 con structor."<<e ndl;nLen gth=l;n Width=w;cout< <"nLen gth=" <<nLen gth<<e ndl< <"n Width=" <<n Width<<e ndl;Rect:Rect(double u, double v)cout<<"executi ng con structor."<<e ndl; mLen gth=u;mWidth=v;cout<&l
9、t;"mLe ngth="<<mLe ngth<<e ndl<<"mWidth="<<mWidth<<e ndl; Rect:Rect()cout<<"executi ng con structor."<<e ndl;int Rect:Area()i nt t;t=nLe ngth* nWidth;return t;double Rect:Area(double u, double v) double r;r=mLe ngth*mWidth;retur
10、n r;void mai n()Rect A(3,4);cout<<"a 的面積="<<A.Area()<<e ndl;Rect B(22,33);cout<<"b 的面積="<<B.Area()<<e ndl;C* "E:Debujvhfbf.eie*遠行結(jié)果:execut ing constructor. nLength=3 nWidtIi=4|的面積12execut ing constkuctai'. nLength=22 nWidth=33h的面積刃毋 ex
11、ecuting constvuctov. executing constructor., PreESkey to continue3 .構(gòu)造一個類countstr ,要求用構(gòu)造函數(shù)設(shè)置計數(shù)器 何值,它要求用戶輸入一段文字, 返回cou nt的整數(shù)值。程序:#in clude<iostream.h>count的初始值為0,成員函數(shù)countcharO不返回任按Enter鍵后結(jié)束計算,用count記錄輸入的字符數(shù),成員函數(shù)getchar()class COU ntstr p ublic:cou ntstrO cou nt=O;void cou ntcharO cout<<&
12、quot;cin> >str;請輸入字符串:"實驗題目實驗六利用友元編程實驗室電信機房實驗時間年 月日實驗類別驗證同組人數(shù)1成績指導(dǎo)教師簽字:while(strcou nt!='O') cou nt+; int getchar() retur n cou nt; p rivate:i nt cou nt;char str200; ; void main() cou ntstr s;s.cou ntchar(); cout<<"the n umber="<<s.getchar()<<e ndl;一、實驗
13、目的1. 掌握友元函數(shù)和友元類的概念、定義和作用。2. 會使用友元編程。3. 進一步學(xué)習(xí)內(nèi)存空間動態(tài)分配和釋放的方法。二、實驗內(nèi)容1有一個向量類 Vector,包括一個點的坐標位置x和y,設(shè)計兩個友元函數(shù),實現(xiàn)兩個向量的加法和減法運算。Print顯示該直線方2定義一個由y=ax+b確定的直線類 Line,該類的構(gòu)造函數(shù)初始化直線,成員函數(shù)程,友元函數(shù)Set Poi nt()求解兩條直線的交點。3.下列程序是有關(guān)友元類的,程序中將A類聲明為B類的友元類,A類中所有的成員函數(shù)都是B類的友元函數(shù),請給程序填空。#in lcude <iostream.h>class B;class A p
14、rivate: int x; p ublic: A(i nt xx)x=xx; int Set(B&); int Get()return x; ;class B private: int x;public:B(i nt xx) frie nd;int A:Set( _ retur n x=b.x;void mai nO A a(10);B b(20);cout<<a.Get()<<e ndl;a.Set(b); cout<<a.Get()<<e ndl;三、編程分析及運行結(jié)果1、#include <iostream.h>cla
15、ss Vector p ublic:Vector(double m=0,double n=0)x=m ;y=n;void dis pl ay() cout<<"("<<x<<","<<y<<")"<<e ndl; frie nd Vector op erator+(Vector &a,Vector &b) Vector t; t.x=a.x+b.x; t.y=a.y+b.y; retur n t; frie nd Vector op erator-
16、(Vector &a,Vector &b) Vector t; t.x=a.x-b.x;t.y=a.y-b.y; retur n t; Vector()private:double x,y;void mai n() Vector a1(8,6),a2(1,2.1),a3,a4;cout<<" 向量 a1=" a1.display();cout<<"向量 a2=" a2.display();a3=a1+a2;cout<<"a1+a2=" a3.dis playO; a4=a1-a2;c
17、out<<"a1-a2=" a4.dis play();2、#include <iostream.h>class Line p ublic:Lin e(double m=0,double n=0)a=m;b=n;void print() cout<<"直線 y="<<a<<"x+"<<b<<""<<endl;void frie nd set poi nt(Li ne & l1,Li ne & l2)H.
18、double x,y;if(l1.a=l2.a) cout<<"兩直線平行,無交點else X=(l1.b-l2.b)/(l2.a-l1.a);y=l1.a*x+l1.b;cout<<"兩直線交點為("<<x<<","<<y<<")"<<endl;Li ne() private:double a,b;void mai nO Line L1(3,5),L2(-2,6);L1. prin t();L2. prin t(); set poi nt(
19、L1,L2);3、填空后程序:#in clude <iostream.h>class B;class A private: int x;public:A(i nt xx)x=xx;int Set(B &);int Get()return x;class Bprivate:int x;p ublic:B(i nt xx)x=xx;frie nd class A;int A:Set(B &b) retur n x=b.x;void mai nO A a(12);B b(34);cout<<a.Get()<<e ndl;a.Set(b);cout&
20、lt;<a.Get()<<e ndl;四、解決方法及難點難點:函數(shù)重載時,注意重載的實現(xiàn)方法:通過形參類型或個數(shù)來區(qū)分調(diào)用哪個函數(shù)。一、實驗?zāi)康牧私饫^承在面向?qū)ο蟪绦蛟O(shè)計中的重要作用。理解繼承與派生的概念,掌握單繼承和多繼承的定義方法。熟悉公有派生和私有派生的訪問特性。掌握繼承中基類和派生類的構(gòu)造函數(shù)定義和調(diào)用過程。了解虛基類的作用和用法,會使用虛基類,學(xué)習(xí)虛基類在解決二義性問題中的作用2.3.4.5.二、實驗內(nèi)容有以下程序,請完成下面的工作:閱讀程序,寫岀運行后的輸岀結(jié)果;然后上機運行,驗證結(jié)果是否正確;分析程序執(zhí)行過程,尤其是調(diào)用構(gòu)造函數(shù)和析構(gòu)函數(shù)的過程。1)2)3)#i
21、n elude <iostream.h>class Ap ublic:A()cout<<A()cout<<“constructing A” <<endl;“destructing A ” <<endl;實驗題目實驗七繼承與派生的編程實驗室電信機房實驗時間年月日實驗類別驗證同組人數(shù)1成績指導(dǎo)教師簽字:;class B:p ublic Ap ublic:B()cout<<B()cout<<class C:p ublic Bp ublic:C()cout<<C()cout<<void mai
22、n() C c1;2. 定義一個"con struct ing B "destruct ing B"con struct ing C “destruct ing CPoint類,派生岀” <<endl; ” <<endl;” <<endl;<<e ndl;Rectangle類和Circle類,計算各派生類對象的面積 Area()。編寫一個完整程序進行測試。3. 定義并描述一個人員類Person,它派生岀學(xué)生類 Student和教師類Teacher,學(xué)生類和教師類共同派生岀在職讀書的教師類Stu_Tech。人員類有姓名
23、、性別、身份證號、岀生年月等信息;學(xué)生類有學(xué)號、成績等信息;教師類有職務(wù)、職稱等信息。編寫一個完整程序進行測試。三、編程分析及運行結(jié)果1、運行結(jié)果:2、class Point public:void inpoin t(double x,double y) Px=x; Py=y;double get PxO return P x;double get PyO return P y;p rotected:double Px, Py;class Recta ngle:p ublic Point public:Recta ngle(double x,double y,double h,double w
24、) inpoin t(x,y); High=h; Wide=w;double getHigh()retur n High; double getWide()return Wide; double Area() return High*Wide; p rotected:double High,Wide;class Circle: public P oi nt public:Circle(double x,double y,double r) inp oi nt(x,y); R=r;double getR() return R;double Area() double pi=3.1415926;
25、return pi*R*R; p rotected:double R;#in clude <iostream.h> void mai n() double x,y,h,w,r;coutvv"請輸入矩形的位置坐標(x,y)、長、寬:"cin> >x>>y>>h>>w;Recta ngle Rect1(x,y,h,w);coutvv"矩形的數(shù)據(jù):"<<endlvv"坐標("<<Rect1.getPx()vv"," <<Rec
26、t1.get Py ()vv"),theigh="vvRect1.getHigh()vv",twidth=" vvRect1.getWide()vv",tArea="vvRect1.Area()vve ndl;coutvv"請輸入圓的位置坐標(x,y)及半徑:"cin> >x>>y>>r;Circle C1(x,y,r);coutvv" 圓的數(shù)據(jù):"vvendlvv" 坐標("vvCI.getPx()vv","vvC1.
27、getPy() vv"),tR="vvC1.getR()vve ndl;3、#include viostream.h> #in clude <stri ng.h> class Person p ublic:P ers onO;P ers on( char *n ame1,char sex1,char *id1,char *birth); void dis playO;P ers onO;p rotected:char *n ame;char *id;char sex;char *birthday;;Person: Person() n ame='0
28、'sex=O; id='O:birthday='0'Person: Person (char *n ame1,char sex1,char *id1,char *birth) n ame=new charstrle n(n ame1)+1; n ame=strc py(n ame ,n ame1); sex=sex1;id=new charstrle n(id1)+1;id=strc py(id,id1);birthday=new charstrle n( birth)+1;birthday=strc py (birthday,birth);void Perso
29、n:dis pl ay() cout< <"n ame:"< <n ame<<"nsex:"<<sex<<"ni d:"<<id<<"nbirthday:"<<birthday<<e ndl;Person: Person() delete name;deleteid; deletebirthday;class Stude ntvirtual p ublic P ers on p ublic:Stude nt(
30、char *n ame,char sex,char *id,char *birthday,l ong int s_n um1,float score1); void dis play() Person:dis pl ay();cout<< "s_n umber:"<<s_ num<<"nscore:"<<score<<e ndl;Stude nt()p rotected:long int s_num; float score;;Stude nt:Stude nt(char *n ame1,cha
31、r sex1,char *id1,char *birth,l ong int s_n um1,float scorel): Pers on(n ame1,sex1,id1,birth) s_n um=s_ num1;score=score1;class Teacher:virtual p ublic P ers on public:Teacher(char *n ame1,char sex1,char *id1,char *birth,char *po sit,char *title1): Perso n(n ame1,sex1,id1,birth) po siti on=new charst
32、rle n(po sit)+1; p ositi on=strc py(po siti on,po sit);title=new charstrle n(title1)+1; title=strc py(title ,titl e1);void dis play() Person:dis pl ay();cout<< "Po sitio n:"<<p ositi on< <"nTitle:"<<title<<e ndl;Teacher() delete positi on;deletetitle
33、;p rotected:char *po siti on;char *title;class Stu_teach:p ublic Stude nt, public Teacher public:Stu_teach(char *n ame1,char sex1,char *id1,char *birth,l ong int s_n um1,float score1,char *p osit,char *title1): Person(n ame1,sex1,id1,birth),Stude nt(n ame1,sex1,id1,birth,s_ num1,score1),Teacher (n a
34、me1,sex1,id,birth ,po sit,title1) void dis play();Stu_teach();void Stu_teach:dis playO Stude nt:dis pl ay();cout<< "Po sitio n:"< <po sitio n<<"nTitle:"<<title<<e ndl;void mai nOs1.dis playO;t1.dis playO;s_t1.dis playO;四、解決方法及難點難點:用虛基類解決繼承和派生時的二義性問題.
35、通過虛基類來實現(xiàn).實驗八利用虛函數(shù)編程一、實驗?zāi)康牧私舛鄳B(tài)性的概念和虛函數(shù)的作用及使用方法。了解靜態(tài)關(guān)聯(lián)和動態(tài)關(guān)聯(lián)的概念和用法。了解純虛函數(shù)和抽象類的概念和用法。學(xué)習(xí)使用虛函數(shù)的繼承實現(xiàn)動態(tài)關(guān)聯(lián)。 學(xué)習(xí)理解靜態(tài)數(shù)據(jù)成員和靜態(tài)成員函數(shù)的使用。、實驗內(nèi)容2.3.4.5.定義基類聲明輸岀函數(shù)受保護成員,派生類可訪問1事先閱讀程序,給岀其運行結(jié)果,上機驗證虛函數(shù)的作用。 有如下程序:#in clude <iostream.h>#in clude <stri ng.h>class Stude nt/p ublic:Stude nt(i nt,stn ngfloat); void
36、dis pl ay();/protected:/int num;stri ng n ame;float score;Stude nt :Stude nt(i nt n, stri ng n am,float s)num=n;n ame=n am;score=s;void Stude nt:dis play()聲明公有派生類cout< <n um: <<n um< <nn ame:< <n ame< <n score:<<score<<e ndl<<e ndl;class Graduate:p ubl
37、ic Stude nt /p ublic:聲明輸岀函數(shù)Graduate(i nt,stri ng,float,flaot);void dis play();/private:float p ay;Graduate:Graduate(i nt n, stri ng n am,float s,flaot p ):Stude nt(n,n am,s), pay(p)void Graduate:dis play()cout< <<n um: <<n um< <nn ame:< <n ame< <n score:<<score
38、< <np ay: <<p ay<<e ndl;void mai n() Stude nt stud(1001, Li,87.5);Graduate grad(2001, Wan g,98.5,563.5);Stude nt *pt=& stud;p t->dis pl ay();pt=&grad;p t->dis pl ay();1) 分析結(jié)果,并驗證之。2) 利用虛函數(shù),對程序作一點修改,在Stude nt類中聲明dis play 函數(shù)時,在其前面加上關(guān)鍵字virtual,即virtual void disp lay();,再
39、編譯運行,注意分析運行結(jié)果。2. 事先編寫一個程序,計算正方體、球體和圓柱體的表面積和體積。(提示:聲明一個抽象基類 container派生類cube、sphere和cylinder ,基類中求表面積和體積的成員函數(shù)聲明為純虛函數(shù)。)3定義一個類Student記錄學(xué)生計算機課程的成績,要求使用靜態(tài)成員變量或靜態(tài)成員函數(shù)計算全班計 算機課程的總成績和平均成績。三、編程分析及運行結(jié)果1、2、#inelude <iostream.h>const double pi=3.1415; class containerp ublic: virtualvoidvirtualvoidvirtualv
40、oiddisp lay()Area()Volume();class cube:p ublic containerp ublic:cube(double a)Le ngth=a;void dis play()cout<<"cube: nLen gth="<<Le ngth<<e ndl; void Area()cout<<"Area="<<6*Le ngth*Le ngth<<e ndl;void Volume()cout<<"Volume="<&
41、lt;Le ngth*Le ngth*Le ngth<<e ndl; cube()p rotected:double Len gth;class sp here:p ublic container public:sp here(double r)R=r;void dis playOcout<<"s phere: nR="<<R<<e ndl;void Area()cout<<"Area="<<4* pi *R*R<<e ndl;void Volume()cout<&
42、lt;"Volume="<<4.0/3* pi*R*R*R<<e ndl;sp here() p rotected:double R;class cyli nder public:cyli nder(double r,double h)R=r;H=h;void dis play()cout<<"cyli nder:nR="<<R<<",thight="<<H<<e ndl;void Area()cout<<"Area="
43、<<2* pi *R*R+2* pi *R*H<<e ndl;void Volume()cout<<"Volume="<< pi*R*R*H<<e ndl;cyli nder() p rotected:double R,H;void mai n() cube cu1(5); cul.dis pl ay(); cu1.Area(); cu1.Volume(); sp here s1(6);sl.dis playO;s1.Area();s1.Volume(); cyli nder cy1(3,8); cy1.dis p
44、lay(); cy1.Area(); cy1.Volume();3、 #inelude <iostream.h> #in clude <stri ng.h> class Stude ntp ublic:Stude nt(l on g,char *,float); void dis playO;Stude nt()delete name; p rotected:static float average;static int sum;long n um;char *n ame;float score;;float Stude nt:average=O;int Stude n
45、t:sum=0;Stude nt:Stude nt(l ong n, char *n am,float s) num=n;n ame=new charstrle n(n am)+1;n ame=strc py( name, nam);score=s;average=(average*sum+s)/(sum+1);sum+;void Stude nt:dis pl ay()coutvv"Number:"v <n um<<"nN ame:"< <n ame<<"nScore:"<<sc
46、ore<<"naverage:"<<average<<e ndl; void mai nOstu1.dis playO;stu2.dis playO;stu3.dis playO;四、解決方法及難點難點:實現(xiàn)函數(shù)多態(tài)性時虛函數(shù)與抽象基類的定義與運用;用靜態(tài)數(shù)據(jù)成員變量體現(xiàn)類中的總體情況。一、實驗?zāi)康牧私膺\算符重載的概念和使用方法掌握幾種常見的運算符重載的方法,通過編程實踐,理解運算符重載的意義。 學(xué)習(xí)內(nèi)存空間動態(tài)分配和釋放的方法。了解在Visual C+6.0 環(huán)境下進行運算符重載要注意的問題。2.3.實驗九運算符重載編程4.二、實驗內(nèi)容
47、1 設(shè)計一個2行3列的矩陣類 Matrix,定義其構(gòu)造函數(shù)、 輸入成員函數(shù)input和輸岀成員函數(shù) dis play , 重載運算符“ + ”,求兩個矩陣的加法?!?、“ <”和“ >”,用于兩2. 定義一個字符串類Stri ng,用來存放不定長的字符串,重載運算符“ 個字符串的等于、小于和大于的比較運算。<<”和流提取符“ >> ”,使之能用于該矩3. 設(shè)計一個2行3列的矩陣類Matrix,重載流插入運算符 陣的輸入和輸岀。三、編程分析及運行結(jié)果1、#inelude <iostream.h> #i nclude <ioma nip .h&g
48、t; class Matrix p ublic:void inp ut();Matrix();void dis play();Matrix op erato 葉(Matrix & m);Matrix()private:float matrix23;void Matrix:i np ut() int i,j;cout<<"請輸入矩陣數(shù)據(jù):"for(i=0;i<2;i+)for(j=0;j<3;j+)ci n>> matrixij;Matrix:Matrix()int i,j;for(i=0;i<2;i+) for(j=0;j&
49、lt;3;j+) matrixij=0;void Matrix:dis play() int i,j;cout<<"矩陣為:n"for(i=0;i<2;i+) for(j=0;j<3;j+) cout<<setw(8)<<matrixij; if(j=2) cout<<e ndl;Matrix Matrix:o perato r +(Matrix &m) Matrix t; int i,j;for(i=0;i<2;i+)fora=0;j<3;j+)t.matrixij=matrixij+m.ma
50、trixij;return t; void mai n() Matrix M1,M2,M3;M1.i np ut();Ml.dis play();M2.i np ut();M2.dis play(); M3=M1+M2; cout<<"M1+M2"M3.dis pl ay();II I "F:C + +i:mDebugDebugiCppl23.e.蠶崇陣數(shù)據(jù)"124 5 請輸入矩陣數(shù)據(jù);5 矩陣為:53 M卄H2矩陣為:8 IM to106 continue612Press any keyl2、#includeviostream.h>#
51、in clude<stri ng.h>class Stri ngprivate:char str20;public:Stri ng();frie nd void op erator=(Stri ng &s1,Stri ng &s2); frie nd void op erator>(Stri ng &s1,Stri ng &s2);frie nd void op erator<(Stri ng &s1,Stri ng &s2); ;Stri ng:Stri ng()cout<<"輸入字符串:"cin> >str;cout<<str<<e ndl;void op erator=(Stri ng &s1,Stri ng &s2)if(strc mp (s1.str,s2.str)=0)cout<<s1.str<<" 等于"<<s2.str<<
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 借錢補充合同范本寫
- 倉儲送貨批發(fā)合同范例
- 一次合同范本
- 關(guān)于轉(zhuǎn)讓車輛合同范本
- 勞務(wù)派遣保潔合同范本
- 產(chǎn)權(quán)經(jīng)紀合同范本
- 出租兒童書架合同范例
- 2025年度化工產(chǎn)品綠色包裝設(shè)計與采購合同
- 修車搬運服務(wù)合同范本
- 2025年精煉銅線項目投資可行性研究分析報告
- 陜西省2024年中考語文真題試卷【附答案】
- 2024年吉林省中考語文真題版有答案
- 中國歷代政治得失-課件
- 課件:森林的基本概念
- 高速公路養(yǎng)護培訓(xùn)
- 如何在小學(xué)語文教學(xué)中落實單元語文要素
- 2024年演出經(jīng)紀人考試必背1000題附答案(黃金題型)
- 安全員繼續(xù)教育考試題庫1000道附參考答案(完整版)
- (2024年)保安培訓(xùn)圖文課件
- 專題16.7 二次根式章末八大題型總結(jié)(拔尖篇)-八年級數(shù)學(xué)下冊(人教版)(解析版)
- 如何提高調(diào)查研究能力
評論
0/150
提交評論