




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、 . . 37/37理工大學城市學院面向?qū)ο蟪绦蛟O(shè)計實訓報告?zhèn)}庫商品檢查登記管理系統(tǒng)專業(yè):班級:學號:指導老師:2012年1月6日目錄目錄1實訓的目的和任務3實訓容指導3倉庫商品檢查登記管理系統(tǒng)類設(shè)計流程圖源代碼程序運行結(jié)果總結(jié)一、實訓的目的和任務C+語言程序設(shè)計的實訓,是教學計劃中的一個有機組成部分,是培養(yǎng)學生綜合應用所學的基礎(chǔ)的理論,基本知識和技能,分析解決實際問題能力的重要一環(huán),與其它教學環(huán)節(jié)緊密配合,相輔相成,是前面教學環(huán)節(jié)的繼續(xù),深入和發(fā)展。通過實訓過程可在不同程度上提高調(diào)查研究,查問文獻,實際應用的能力。二、實訓容指導(一)數(shù)據(jù)類型和表達式基礎(chǔ)實訓1、定義一個描述學生的結(jié)構(gòu)體類型s
2、tudent,含有學號num、name、性別sex、成績score幾個分量,再定義屬于這個結(jié)構(gòu)體類型的兩個變量stu1、stu2。struct studentintnum; /* 學號 */char name20;/* */char sex; /* 性別 */floatscore; /* 成績 */; struct student student1, student2;2、建立一個適于描述碗和勺子的結(jié)構(gòu)體,有關(guān)的信息是:兩者都有貨號、價格、顏色,不同的是碗的大小用口徑來表示,勺子的大小用枚舉類型表示,分大、中、小三種?,F(xiàn)有的勺子的大小是中,將其表示出來。#include using names
3、pace std;struct bowl int No; int price; char color; float size;struct spoon int No; int price; char color; struct enum small,medium,bigshaozi; a;b;void main() b.a.shaozi = b.a.medium; coutb.a.shaozi;3、編程實現(xiàn)兩個整數(shù)相加。#includeint main()int integer1,integer2,sum; coutinteger1; coutinteger2; sum=integer1+in
4、teger2; coutSum is sum endl; return; 4、編程實現(xiàn),輸入一個三位整數(shù),能夠?qū)⑺聪蜉敵觥?include #include using namespace std; void main() int num; coutnum; while(num) coutnum%10; num /=10; coutendl;5、讀程序?qū)懡Y(jié)果。綜合實訓數(shù)字互換實訓。輸入一個大于三位的整數(shù),編一個程序,將它的十位數(shù)和百位數(shù)互換位置。#includeusing namespace std;int main() int x; int a3; cinx; for(int i=0;i3
5、;i+) ai=x%10;x=x/10; x=x*1000+a0+a1*100+a2*10; coutxendl; return 1;(二)語句和函數(shù)基礎(chǔ)實訓1、根據(jù)考試成績的等級A、B、C和D,輸出對應的百分制分數(shù)段,A對應85100,B對應7084,C對應6069,D對應060。#define num 100int a=new int num;for(int i=0;i=85)cout=70)cout=60)coutC;elsecoutD;2、用for語句編程求1100之和。#includevoid main()int sum(0);for(int i=1;i=100;i+)sum+=i;
6、coutsum=sumendl;3、用for語句、while語句和遞歸函數(shù)三種方法計算n!。#includemain()int n;int sum=1;cin0;) sum*=n-;while(n0) sum*=n-; int f(int x) if(x1) x*=f(x-1); return x; else return x; 4、用for循環(huán)編程打印圖形。#include using namespace std;int main() for(int i=1;i=5;i+) for(int j=1;j=i;j+) cout*; coutendl; cout*endl; cout*endl;5
7、、編寫函數(shù),判斷一個數(shù)是否是質(zhì)數(shù)。# include# includeusing namespace std;int main()int i,j,k;cinj;k=sqrt(j);for(i=2;ik)cout1;else cout0;return 0;9、設(shè)計一個函數(shù),求三個數(shù)中的最大值。#includeint max(int,int,int);void main()coutmax(35,48,26)endl;int max(int a,int b,int c)int t=max(a,b);return max(t,c);10、編寫程序,利用itoa函數(shù)實現(xiàn)整數(shù)到字符串的轉(zhuǎn)換。#includ
8、eintitoa(x)charc;c=x;printf(%c,c);getch();intmain(void)inta;printf(inputanumber:);scanf(%d,&a);itoa(a);11、編寫程序,最多讀入10個數(shù),讀入0表示結(jié)束。將讀入的非零的數(shù)放在一個數(shù)組里,按從大到小的順序排序后輸出。#include #include#include#includeusing namespace std;int main()/主函數(shù) vector b; for(int i=0;ix; if( x ) b.push_back( x ); else break; sort( b.be
9、gin(),b.end() ); copy( b.begin(),b.end() , ostream_iterator(cout, ) ); return 0;12、將一個代表整型數(shù)的字符串轉(zhuǎn)換為一個整型的數(shù)字。#include #include #include using namespace std;int main(int argc, char* argv) stringstream a; string b; int i; cinb; a.str(b); ai; couti*2endl; return 0;綜合實訓(職工信息處理函數(shù)實訓)職工的信息有、年齡、工齡、性別、婚姻狀況、級別、工
10、資、在職否?,F(xiàn)在要進行工資的調(diào)整,規(guī)定凡是退休職工一律增加工資50元,在職15級職工的工資分別增加20、40、60、80、100元。編程實現(xiàn)上述工資調(diào)整。要求如下:(1)分析要存放的信息,設(shè)計合適的數(shù)據(jù)結(jié)構(gòu);(2)分析要對信息進行的操作,進行處理;(3)打印程序執(zhí)行前后的工資狀況和級別。(三)面向?qū)ο蠡靖拍钆c類實訓基礎(chǔ)實訓1、讀程序?qū)懡Y(jié)果;2、設(shè)計一個表示貓的類,包括貓的顏色、體重、年齡等數(shù)據(jù),具有設(shè)置貓的顏色,修改和顯示貓的體重、年齡等操作。設(shè)貓類的類名為Cat,貓類Cat有3個數(shù)據(jù)成員,顏色用字符串color7,可以存放3個漢字,體重用實型數(shù)weight表示,年齡用整型數(shù)age表示,為了
11、數(shù)據(jù)的安全性,Cat的3個數(shù)據(jù)成員全部為私有的。對貓的屬性數(shù)據(jù)的設(shè)置和修改,PutColor為設(shè)置和修改顏色,PutWeight為設(shè)置和修改體重,PutAge為設(shè)置和修改年齡,它們都設(shè)置為公有函數(shù),還要有一個1個3個參數(shù)的函數(shù) SetCat。設(shè)計Display函數(shù)輸出貓的信息。#include class Catprivate String colour;private int weight;private int age;.int getWeight() return weight;int getAge() return age;void setClolur(String xClolour)
12、 colour=xCloour;void setWeight(int xWeight) weight=xWeight;void setAge(int xAge) age=xAge;設(shè)計一個表示學習成績的類,至少包括三門課程的成績,可以設(shè)置、顯示每門課程的成績,可以計算、顯示平均成績。class Gradesprivate: int Math,English,Chinese;public: Grades() Math = English = Chinese = 0; Grades(int a,int b,int c) Math = a; English = b; Chinese = c; int
13、 getM() return Math; int getE() return English; int GetC() return Chinese; void Setvalue(int a,int b,int c) Math = a; English = b; Chinese = c; void Display(); float Average() return (Math+English+Chinese)/3.0; 4、設(shè)計成績類,成績類的數(shù)據(jù)成員,應該包括學生的學號Number10和Name9,假設(shè)有3門課,分別為C+程序設(shè)計語言,用整型變量Cpp表示;計算機原理,用整型變量Compute
14、r表示;數(shù)據(jù)庫,用整型變量DataBase表示。平均成績用實型變量Average表示。為了Grade類數(shù)據(jù)的安全性,數(shù)據(jù)成員全部為私有成員,對成績類的屬性數(shù)據(jù)用一些函數(shù)進行設(shè)置和修改,PutNo為設(shè)置和修改學號,PutName為設(shè)置和修改,PutCpp為設(shè)置和修改C+程序設(shè)計語言的成績,PutCom為設(shè)置和修改計算機原理的成績,PutData為設(shè)置和修改數(shù)據(jù)庫的成績,還有一個同時設(shè)置所有5個參數(shù)的函數(shù)SetGrade,它們都設(shè)置為公有函數(shù)。計算平均成績的函數(shù)為Calc,設(shè)計函數(shù)Display輸出成績。有時可能要查看某個學生的成績,所以設(shè)計比較學號的函數(shù)為ComNo,設(shè)計比較的函數(shù)為ComNam
15、e,GetCpp為讀取C+程序設(shè)計語言的成績,GetCom為讀取計算機原理的成績,GetData為讀取數(shù)據(jù)庫的成績,設(shè)計讀取平均成績的函數(shù)為GetAvg。計算平均成績只是在類的部實現(xiàn),所以設(shè)計為私有函數(shù),其它都為公有函數(shù)。綜合實訓設(shè)計一個表示整型數(shù)據(jù)的集合類,可以對集合中的數(shù)據(jù)進行添加、刪除,可以判斷一個整數(shù)是否在這個集合里,可以求出集合數(shù)據(jù)的多少,可以判斷集合的空與滿,空集合就是沒有數(shù)據(jù)元素,滿集合就是數(shù)據(jù)元素已經(jīng)占滿給出的存儲單元。兩個集合可以做交運算,就是將兩個集合的公共數(shù)據(jù)組成一個新的集合。兩個集合可以做并運算,就是將兩個集合的所有數(shù)據(jù)組成一個新的集合。要求如下:(1)分析集合類的數(shù)據(jù)
16、屬性要求;(2)分析集合類的操作屬性要求;(3)編制集合類的接口定義;(4)實現(xiàn)集合類的屬性函數(shù)。#include/form the datastruct Data long num; Data *next;/the set classclass Gather public: Gather(int =5); /Gather(); void form(int); void del(); void setGather(); void print(); void add(int); Data *getptr()return ptr; Gather& operator=(Gather &); Gath
17、er& operator+(Gather &); Gather& operator*(Gather &); private: int LEN; Data *ptr;Gather inside;Gather:Gather(int a)form(a);void Gather:form(int a) LEN=a; Data *p; for (int i=0;inext=new Data; p=p-next; p-next=NULL;/Gather:Gather()del();void Gather:del() Data *p; Data *q; p=ptr; for(int i=0;inext; d
18、elete q; LEN=0;void Gather:setGather() Data *p; p=ptr; for (int i=0;iLEN;i+) coutEnter item i+1p-num; p=p-next; void Gather:print() if (LEN=0) coutIts an empty set!endl; Data *p; p=ptr; for(int i=0;iLEN;i+) coutnumnext; if (i!=0&i%10=0) coutendl; void Gather:add(int t) bool y=true; Data *p; p=ptr; f
19、or(int i=0;inum=t) y=false; break; if(i!=LEN-1)p=p-next; if(y) p-next=new Data; p=p-next; p-num=t; p-next=NULL; LEN+; Gather& Gather:operator =(Gather &x) if (ptr=x.ptr) return *this; else del(); form(x.LEN); Data *p,*q; p=ptr; q=x.ptr; for(int i=0;inum=q-num; p=p-next; q=q-next; return *this; Gathe
20、r& Gather:operator +(Gather &x) inside.del(); inside.form(LEN); Data *q; Data *p; q=ptr; p=inside.getptr(); for(int i=0;inum=q-num; p=p-next; q=q-next; q=x.ptr; for(i=0;inum); q=q-next; return inside;Gather& Gather:operator *(Gather &x) int z=0; long g100; bool y=true; Data *p; Data *q; p=ptr; q=x.p
21、tr; for(int i=0;iLEN;i+) q=x.ptr; for(int j=0;jnum=q-num) for(int t=0;tnum=gt) y=false; break; if(y) gz=p-num; z+; break; y=true; break; else q=q-next; p=p-next; inside.del(); inside.form(z); Data *pre; pre=inside.getptr(); for (i=0;inum=gi; pre=pre-next; return inside;/the mainint main() Gather x(6
22、); Gather y; Gather result; coutEnter the item of set x:endl; x.setGather(); coutThe items of x is:endl; x.print(); coutendl; coutEnter the item of set y:endl; y.setGather(); coutThe items of y is:endl; y.print(); coutendl; coutThe result of x+y is:endl; result=x+y; result.print(); coutendl; coutThe
23、 result of x*y is:endl; result=x*y; result.print(); coutendl; couta; x.add(a); coutNow x is : ;x.print(); coutendl; inside.del(); result.del(); x.del(); y.del(); return 0;(四)對象實訓基礎(chǔ)實訓1、讀程序?qū)懡Y(jié)果;2、設(shè)計計算圖形面積的程序,圖形有圓和長方形,計算半徑為15、23、37的圓和長寬分別為(32,56)、(21,45)的長方形等五個圖形的面積。class rect private: float length; flo
24、at width; public: rect(float l,float w); void putwidth(float w); void putlength(float l); float getwidth()const; float getlength()const; float Area()const; float Total()const; ; rect:rect(float l=0 ,float w=0) length=l; width=w; void rect:putwidth(float w) width=w; void rect:putlength(float l) lengt
25、h=l; float rect:getlength()const return length; float rect:getwidth()const return width; float rect:Area ()const return length*width; float rect:Total ()const return 2*(length+width); /rect.cpp #include #include #include rect.h #include using namespace std; void main() cout 求長方形的面積與周長 endl; int str=
26、0; float rw,rl; rect a(0,0); ttt: cout rl rw;/此處輸入字符時就會錯誤 a.putlength (rl); a.putwidth (rw); do cout 輸入0為退出,輸入1求面積,輸入2求周長,3是輸入長和寬 str; switch (str) case 1: cout 面積是: a.Area () endl; break; case 2: cout 周長是: a.Total () endl; break; case 3: goto ttt; break; case 0: cout ByeBye! endl; break; default: c
27、out 錯誤!輸入1求面積,輸入2求周長! endl; break; while(str);/*/ getch(); 3、設(shè)計一個日期類Date,可以求昨天的日期和明天的日期,輸出格式為:年/月/日,編寫主程序設(shè)置當前日期為2003年9月10日,顯示昨天的日期和明天的日期,將日期改為2004年5月4日,顯示修改后的日期。綜合實訓設(shè)計一個最多可以存放100個整數(shù)的類,要求這些整數(shù)按從小到大的順序存放在類中的數(shù)組里,可以刪除數(shù)組中的數(shù)據(jù),也可以向數(shù)組中插入數(shù)據(jù),但是要保持從小到大的順序,可以求出數(shù)據(jù)的多少,可以判斷數(shù)組的空和滿,可以顯示數(shù)組中的整數(shù)。當然剛生成對象時,對象中的數(shù)組沒有數(shù)據(jù),只有一個
28、一個地向?qū)ο笾胁迦霐?shù)據(jù)。要求如下:(1)分析數(shù)組類的數(shù)據(jù)屬性要求;(2)分析數(shù)組類的操作屬性要求;(3)編制數(shù)組類的接口定義;(4)生成數(shù)組類對象;(5)編制程序?qū)崿F(xiàn)數(shù)組對象的插入和刪除操作;#includeclass Dateprivate:int year,month,day;public:Date(int y=1900,int m=1,int d=1):year(y),month(m),day(d)/構(gòu)造函數(shù)void setDate(int y,int m,int d)/設(shè)置日期 year=y; month=m; day=d;void showDate()/輸出日期格式 coutyear
29、/month/dayendl;int leap()/判斷是否為潤年 if(year%400=0|(year%100!=0&year%4=0) return 1; else return 0;int Days()/判斷當月天數(shù) int d; switch(month) case 2:if(leap() d=29; else d=28; break; case 1: case 3: case 5: case 7: case 8: case 10: case 12:d=31;break; case 4: case 6: case 9: case 11:d=30;break; return d;int
30、 isRight()/判斷日期數(shù)是否合理if(year0|month12|dayDays() coutthe date data is wrong!endl;return 0;else return 1;Date Yesterday()/求昨天Date dt(year,month,day);int y1=dt.year,m1=dt.month,d1=dt.day;switch(month) case 2: case 4: case 6: case 8: case 9: case 11: if(day=1)y1=year;m1=month-1;d1=31; else y1=year;m1=mon
31、th;d1=day-1; break; case 5: case 7: case 10: case 12: if(day=1)y1=year;m1=month-1;d1=30; else y1=year;m1=month;d1=day-1; break; case 3: if(day=1) y1=year;m1=month-1; if(leap() d1=29; else d1=28; else y1=year;m1=month;d1=day-1; break; case 1: if(day=1)y1=year-1;m1=12;d1=31; else y1=year;m1=month;d1=d
32、ay-1; break; dt.setDate(y1,m1,d1);return dt;Date Tomorrow()/求明天日期 Date dt(year,month,day);int y1=dt.year,m1=dt.month,d1=dt.day;switch(month) case 1: case 3: case 5: case 7: case 8: case 10: if(day=31)y1=year;m1=month+1;d1=1; else y1=year;m1=month;d1=day+1; break; case 4: case 6: case 9: case 11: if(
33、day=30)y1=year;m1=month+1;d1=1; else y1=year;m1=month;d1=day+1; break; case 2: if(leap()&day=29)|(!leap()&day=28) y1=year;m1=month+1;d1=1; else y1=year;m1=month;d1=day+1; break; case 12: if(day=31)y1=year+1;m1=1;d1=1; else y1=year;m1=month;d1=day+1; break; dt.setDate(y1,m1,d1);return dt; ;/data類結(jié)束in
34、t main()Date date1;int y,m,d,tr=1;while(tr)coutt請輸入當天日期endl;couty;coutm;coutd; date1.setDate(y,m,d);if(date1.isRight()cout當日日期; date1.showDate(); cout明日日期; date1.Tomorrow().showDate(); cout昨日日期; date1.Yesterday().showDate(); cout繼續(xù)下一次測試(1)或者結(jié)束(2)tr; if(tr!=1) break;return 0;(五)指針與引用實訓基礎(chǔ)實訓1、讀程序?qū)懡Y(jié)果;2、
35、設(shè)有一個整型數(shù)組A,有10個元素,輸出各個元素,要求使用數(shù)組名和指針運算來實現(xiàn)。3、設(shè)計一個函數(shù),以參數(shù)方式輸入一個字符串,返回該字符串的長度。#includeint mystrlen(char *str)intt = 0;while(cnt+,*str+);returnt-1;int main()char str100;int length;cout輸入字符串:str;length = mystrlen(str);coutstr長度為:lengthendl;return 0;4、設(shè)計一個函數(shù),比較兩個字符串是否一樣。#include #include void main()char str1
36、100,str2100;cout輸入兩個字符串(str1,str2):str1str2;int ret=strcmp(str1,str2);if(ret=0)cout一樣endl; else cout不同endl; 4、設(shè)計一個函數(shù),比較兩個字符串是否一樣。int myStrCmp(char *str1,char *str2) int sl1=0,sl2=0,i; while(str1sl1+); while(str2sl2+); if(sl1!=sl2) return 0; else for(i=0;isl1-1;i+) if(str1i!=str2i) return 0; return 1
37、;5、用指針和引用實現(xiàn)數(shù)的交換。#include #includevoid swap1(int &a, int &b) int c; c=a; a=b; b=c;void swap2(int *p1, int *p2)int p;p=*p1;*p1=*p2;*p2=p;int main(void)int num1, num2;cout(&num1,&num2):num1num2;cout(原始數(shù)據(jù):num1,num2):num1,num2endl;swap1(num1,num2);cout第一次交換:num1,num2endl;swap2(&num1,&num2);cout第二次交換:num1
38、,num2endl;return 0;6、對象指針遵循一般變量指針的規(guī)則。綜合實訓冒泡排序是一個排序程序,它將無次序的數(shù)列排成從小到大的有序數(shù)列。要求如下:(1)建成一個數(shù)組類;(2)使用指針變量指向動態(tài)數(shù)組;(3)編寫成員函數(shù)完成排序;(4)編寫主程序,驗證結(jié)果。(六)繼承實訓基礎(chǔ)實訓1、讀程序,寫結(jié)果;2、定義B0是虛基類,B1和B2都繼承B0,D1同時繼承B1和B2,它們都是公有派生,這些類都是同名的公有數(shù)據(jù)成員和公有函數(shù),編制主程序,生成D1的對象,通過限定詞:分別訪問D1、B0、B1、B2的公有成員。3、定義一個文件名類,包含文件名屬性。由文件名類派生一個表示文件的類,增加文件的頁數(shù)
39、和文件的編號。4、設(shè)計一個樓房基類,包含變量層數(shù)、建筑面積、建筑名稱。建立派生類表示居住樓,增加變量單元數(shù)。再建立派生類表示辦公樓,增加變量表示公司數(shù)# include # include using namespace std;class building/樓房基類public: building(int floor,double area,string name)floors=floor;areas=area;names=name; virtual void Display()const/* do something like print*/private: int floors; dou
40、ble areas; string names;/建筑名稱;class house:public buildingpublic: house(int floor,double area,string name,int domitory):building(floor,area,name)ds=domitory; void Display()const/* do the thing you want to do*/private: int ds;class office:public building/不知道你是要從building 繼承 還是house 這從buiding 繼承public:
41、office(int floor,double area,string name,int CompanySize):building(floor,area,name)cs=CompanySize; void Display()const/*print or something*/private: int cs;void DoSmeThing(building *p) p-Display();void main() building Bd(5,60,paradise); house Hs(4,56.8,home,5); office Of(9,70.8,HDD,100); DoSmeThing(
42、&Bd); DoSmeThing(&Hs); DoSmeThing(&Of);定義描述坐標位置的類,由它派生出具有顯示和移動功能的點類,再從點類派生出圓類,求出圓的周長和面積。circle_header.h#ifndef CIRCLE_H#define CIRCLE_H#include #include using namespace std;#define PI 3.1416class Locationpublic:Location(float xx=0, float yy=0)X=xx; Y=yy; float GetX()return X; float GetY()return Y; v
43、oid SetX(float xx)X = xx; void SetY(float yy)Y = yy;private: float X; float Y;class Point:public Locationpublic: void Move(float xx, float yy) SetX(xx); SetY(yy); void Display() coutThe location is x= GetX() , y= GetY(); private: Location PointLocation;class Circle:public Pointpublic: Circle(Locatio
44、n ¢re, Point &circlePoint) CirclePoint = circlePoint; Centre = centre; float Girth() return 2*PI*Radius(); float Acreage() return PI*Radius()*Radius(); private: Location Centre; Point CirclePoint; float Radius() return sqrt( (CirclePoint.GetX()-Centre.GetX()*(CirclePoint.GetX()-Centre.GetX()+ (C
45、irclePoint.GetY()-Centre.GetY()*(CirclePoint.GetY()-Centre.GetY() ); ;#endiffile.cpp#include circle_header.hvoid main() Location centre(1, 2); Point point; point.Move(4, 5); Circle circle(centre, point); cout circle.Acreage() circle.Girth() endl;綜合實訓人員類的繼承實訓;(設(shè)計基類人員類,數(shù)據(jù)成員為和身份號,成員函數(shù)有輸入數(shù)據(jù)和顯示數(shù)據(jù);派生學生類,數(shù)
46、據(jù)成員包括和C+成績,成員函數(shù)有輸入數(shù)據(jù)和顯示數(shù)據(jù);設(shè)計學生地址類,數(shù)據(jù)成員包括地址和年齡,成員函數(shù)輸入數(shù)據(jù)和顯示數(shù)據(jù);由學生類和地址類派生學生成績類,數(shù)據(jù)成員數(shù)學成績和英語成績,成員函數(shù)輸入數(shù)據(jù)和顯示數(shù)據(jù);職員類繼承人員類,沒有任何成員。)要求如下:(1)設(shè)計人員類;(2)設(shè)計地址類;(3)由人員類派生學生類;(4)由人員類派生職員類;(5)由學生類和地址類派生出學生成績類;(6)編制主程序,驗證結(jié)果。(七)靜態(tài)成員和友元實訓#include#includeusing namespace std;class Personprivate: string name; string id;publ
47、ic : void input(string name,string id) this-name=name; this-id=id; void print() cout:nameendl; cout號:idadd=add; this-age=age; void print() cout住址:addendl; cout年齡:agephone_num=phone_num; this-grade_C=grade_C; void print() Person:print(); cout:phone_numendl; coutC+成績:grade_Cgrade_Math=grade_Math; this
48、-grade_English=grade_English; void print() Student:print(); cout數(shù)學成績:grade_Mathendl; cout英語成績:grade_Englishendl; Address:print(); ;class Employee:public Person;int main() Score c; Employee e; c.input (,2002001, ,20,87935114,97,88,56); e.input(麻婷,123456); coutn學生信息n; c.print(); coutn職員信息n; e.print();
49、 return 0;基礎(chǔ)實訓1、定義一個工資類,包含一個保護數(shù)據(jù)成員money 表示工資,一個靜態(tài)數(shù)據(jù)成員sds表示個人所得稅占工資的比例,一個靜態(tài)成員函數(shù)modSDS更改sds。#include#includeclass Payrollprivate: double money; double total;public: int time;/假設(shè)為整數(shù) int GetTime() do printf(input time:); scanf(%d,&time); while(time60 ); money = 100; return 0; int GetTotalMoney() return
50、(total =time * money); void Print() printf(total:%lfn,total); ;main() Payroll p10; p0.GetTime(); p0.GetTotalMoney(); p0.Print();贊同2、生成一個GZ類表示工資,用靜態(tài)數(shù)據(jù)成員包含每個職工的sds(個人所得稅占工資的比例)。類的每個成員包含一個私有數(shù)據(jù)成員money,表示當月工資。提供一個calSDS成員函數(shù),計算個人應交所得稅,并從money中扣除。提供一個static成員函數(shù)modSDS,將sds設(shè)置為新值。3、設(shè)計一個JX類表示矩形,矩形的長和寬作為其兩個數(shù)據(jù)成員。編寫一個求矩形面積的函數(shù)area(),并將它聲明為JX的一個友元函數(shù)。利用area()
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中國新式茶飲行業(yè)市場競爭格局及投資方向研究報告(智研咨詢)
- 七年級下冊《三元一次方程組的解法》課件與練習
- 構(gòu)建平臺用戶個人信息保護制度
- 2025年衛(wèi)星數(shù)據(jù)采集系統(tǒng)項目合作計劃書
- 農(nóng)業(yè)技術(shù)研發(fā)推廣合作協(xié)議
- 裝修房屋委托合同
- 餐飲業(yè)食品安全保障與事故免責協(xié)議書
- 2025年工業(yè)廢氣凈化裝置項目發(fā)展計劃
- 2025年微球載體材料項目發(fā)展計劃
- 醫(yī)療美容服務項目風險告知與免責協(xié)議
- 路面彎沉溫度修正系數(shù)
- 寫給所有人的數(shù)學思維課
- 黑龍江省哈爾濱重點中學2023-2024學年高二上學期期中考試語文試題(含答案)
- 讀書分享讀書交流會《給教師的建議》課件
- 工程量清單及招標控制價編制、審核入庫類服務方案
- 語文教師公開課評價表
- toc測定儀的原理及使用(ppt頁)
- 委托辦理公證委托書(6篇)
- 康復醫(yī)學緒論
- 大樹修剪專項施工方案
- 對違反政治紀律行為的處分心得體會
評論
0/150
提交評論