




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、c+程序設(shè)計(jì)課 程 設(shè) 計(jì) 說 明 書題目名稱:學(xué)生學(xué)號(hào):學(xué)生姓名:指導(dǎo)老師:2011年3月25目 錄第一部分 基礎(chǔ)程序1一、程序代碼1二、運(yùn)行結(jié)果及分析16第二部分 綜合問題20一、需求分析20二、設(shè)計(jì)21三、編碼與調(diào)試22四、結(jié)果分析23五、參考資料24六、總結(jié)25第一部分 基礎(chǔ)程序一、 程序代碼(1) #include using namespace std;const int max=100;void main()int smax,i,x,q,n=10; cout輸入個(gè)有序數(shù)列endl;for(i=0;isi;cout數(shù)列為: ;for(i=0;in;i+)coutsi ; coutx
2、;for(i=0;in;i+) if(x=q;i-) si+1=si; sq=x; cout輸出n個(gè)有序數(shù)列為; for(i=0;in;i+) coutsi ; (2) #include using namespace std;const int max=100;void main()int smax,i;int sum=0; cout輸入個(gè)數(shù)endl; for(i=0;isi;cout數(shù)列為: ;for(i=0;i20;i+)coutsi; for(i=0;i20;i+)if(si%2=0)coutsi ; sum=si+sum; cout和為sum; (3) #include using
3、namespace std;int lj(int i);void main () int result=0,n,i; cout1+(1+2)+(1+2+3)+(1+2+.+n);cout 輸入n:n;for(i=1;i=n;i+)result=lj(i)+result;cout和為resultendl;int lj(int i) int sum=0,a;for(a=1;a=i;a+) sum=sum+a;return sum; (4) #include using namespace std;double ss(int n);void main ()int i;cout50-100的素?cái)?shù)有:;
4、 for(i=50;i=100;i+)if(ss(i) couti ;double ss(int n)int i;for(i=2;in;i+)if(n%i=0)break;if(i=n)return 1;else return 0;(5) #include using namespace std;const int max=100;double aveage(int s);void main()int smax,i;double ave; coutenter 10 students score;for(i=0;isi;ave=aveage(s);cout ave is:aveendl;doub
5、le aveage(int s)int ave=0,i;for(i=0;i10;i+)ave=ave+si;return double (ave)/10;(6) #include using namespace std;double leg(char str);void main () char str81; cout str; leg(str); coutstr;double leg(char str) int n,i,temp;n=strlen(str);for(i=0;in/2;i+) temp=stri; stri=strn-1-i; strn-1-i=temp;return *str
6、;(7)#include using namespace std;const int max=100;void main ()int n=10; int*p,smax,*max,*min;int sum=0;double ave;coutenter n numbers;for(p=s;p*p;coutnumber is: ;for(p=s;ps+n;p+)cout*p ;coutendl;max=s;min=s; for(p=s;p*max)max=p; for(p=s;ps+n;p+)if(*p*min)min=p; coutmax is *maxendl;coutmin is *minen
7、dl; for(p=s;ps+n;p+)sum+=*p; ave=(1.0*sum)/n;coutaveage is aveendl;(8) #include using namespace std;const int max=100;void main() char str181,str281; char *p,*q; cout enter a stringstr1; coutenter another stringstr2; for(p=str1;*p!=0;p+); for(q=str2;*p=*q;p+,q+); coutstr1endl;(9) #include using name
8、space std;class scoreprivate:int number; int computer;int english; double average;public: void inscore(double xx,double yy ,double zz); void showscore();void score:inscore(double xx,double yy,double zz)number=xx; computer=yy;english=zz;average=(english+computer)/2.0;void score:showscore()coutnumber
9、computer englishendl;coutnumber computer englishendl;coutaverage is : averageendl;void main()int x,y,z;int x1,y1,z1; score stu1,stu2,*p=&stu2;coutenter number and computer score .english scorexyz;coutenter another number and computer score .english scorex1y1z1; stu1.inscore(x,y,z);stu1.showscore();
10、stu2.inscore(x1,y1,z1);p-showscore(); (10) #includeusing namespace std;class studentint num; char sname50; double score;public:void setdata();void display();double getscore()return score;void student:setdata()coutenter students number:num;coutenter students name:sname;coutenter the score:score;void
11、student:display()coutnumber name score endl;coutnum sname scoreendl;class manageint i,num;student s80;public: void input(int n); void sort(); void output();void manage:input(int n)num=n;for(i=0;inum;i+) si.setdata();void manage:sort() student temp; int pos,j;for(i=0;inum;i+)pos=i;for( j=i;jspos.gets
12、core()pos=j;if(pos!=j)temp=spos;spos=si;si=temp;void manage: output()sort();for(i=0;inum;i+)si.display();void main()int n;manage m;couthow many students do you want to enter:n;m.input(n);m.output(); (11) #include#includeusing namespace std;class objectpublic:char name50;int number;class book:public
13、objectprivate:char autour50;public:void set(); void display();void book:set()cout書名:name;cout作者:autour;void book:display()cout書名: ;coutnameendl;cout作者: ;coutautourendl;cout書號(hào): ; coutnumberendl;class reader:public objectprivate:int max;public:void set(); void display();void reader:set()cout讀者姓名:name;
14、 cout最多借書數(shù)量:max;void reader:display() cout讀者姓名: ; coutnameendl; cout借書證號(hào): ; coutnumberendl; cout最多借書數(shù)量: ; coutmaxendl;void main()book p;reader q;coutp.number;p.set();p.display();coutq.number;q.set();q.display();(12)#include#includeusing namespace std;const double pi=3.14;class shapepublic:virtual do
15、uble area()=0;class square:public shapepublic:square(int m);double area();private:int n;square:square(int m)n=m;double square:area()return n*n;class circle:public shapepublic:circle(double r);double area() ;private:double radius;circle:circle(double r)radius=r;double circle:area() return pi*radius*r
16、adius;class chang:public shapepublic:chang (int a,int b);double area();private:int x;int y;chang:chang(int a,int b)x=a;y=b;double chang:area()return x*y;class triangle:public shapepublic:triangle(double x,double y,double z) ;double area();private:double a;double b;double c;triangle:triangle(double x
17、,double y,double z)a=x;b=y;c=z;double triangle:area()double m,s;m=(a+b+c)/2;s=sqrt(m*(m-a)*(m-b)*(m-c);return s;void main() int a,b,c,d,e,f,g; cout a; shape *s=new square(a); cout正方形面積:area()endl;delete s; cout b; shape *p=new circle(b);cout圓面積:area()endl; delete p; cout cd;shape *c=new c24hang(c,d)
18、;cout長(zhǎng)方形面積:area()endl; delete c; cout efg;shape *t=new triangle(e,f,g);cout三角形面積:area()endl;delete t;(13) #includeconst int maxsize=100;templatevoid sort(t s,int n);void main()int i,n;int smaxsize;char m20;coutn;coutenter n numbersn;for(i=0;isi;sort(s,n);coutsorted numbers:endl;for(i=0;in;i+)coutsi
19、;coutendl;coutn;coutenter n string:n;for(i=0;imi; sort(m,n);coutsorted char:endl;for(i=0;in;i+)coutmi ; coutendl;templatevoid sort(t s,int n)int i,j,pos;for(i=0;in-1;i+)pos=i;for(j=i;jspos)pos=j;if(pos!=i)t t; t=si;si=spos;spos=t;(14) #include#includeusing namespace std;void main()char str100;int i=
20、0;ifstream data(data.txt,ios:in);ofstream data1(data1.txt,ios:out);if(!data)cerrcannor open file!endl;abort();while(!data.eof()data.getline(str,100);data1+itstrendl;coutstrendl;data.close();data1.close();cout共ishowscore();”結(jié)果:enter number and computer score .english score1 99 100enter another number
21、 and computer score .english score2 78 98number computer english1 99 100average is : 99.5number computer english2 78 98average is : 88press any key to continue第十題:分析:enter number and computer score .english score1 99 100enter another number and computer score .english score2 78 98number computer eng
22、lish1 99 100average is : 99.5number computer english2 78 98average is : 88press any key to continue第十一題:分析:輸入書號(hào):1書名:sheeeeee作者:cong書名: sheeeeee作者: cong書號(hào): 1輸入借書證號(hào):2008讀者姓名:bin最多借書數(shù)量:5讀者姓名: bin借書證號(hào): 2008最多借書數(shù)量: 5press any key to continue第十二題:分析:輸入正方形邊長(zhǎng) 2正方形面積:4 輸入 圓半徑 2圓面積:12.56 輸入 長(zhǎng), 寬 2 3長(zhǎng)方形面積:6 輸入
23、三條邊 3 4 5三角形面積:6press any key to continue第十三題:分析:enter a numbers:2enter 2 numbers1223sorted numbers:23 12enter a numbes:2enter 2 string:d gsorted char:g dpress any key to continue第十四題:分析:要新建 data。txt文件夾congbin共 2 行press any key to continue第二部分 綜合問題一、需求分析需求分析即問題的描述,根據(jù)設(shè)計(jì)題目的要求,充分地分析和理解問題,明確問題要求做什么,限制條件
24、是什么。在確定解決方案框架過程中,綜合考慮系統(tǒng)功能,考慮怎樣使系統(tǒng)結(jié)構(gòu)清晰、合理、簡(jiǎn)單和易于調(diào)試。最后確定系統(tǒng)的功能模塊以及模塊之間的調(diào)用關(guān)系。 二、設(shè)計(jì)分析對(duì)問題描述中涉及的操作對(duì)象定義相應(yīng)的類,并按照以數(shù)據(jù)結(jié)構(gòu)為中心的原則劃分模塊,定義主程序模塊和各抽象數(shù)據(jù)類型。邏輯設(shè)計(jì)的結(jié)果應(yīng)寫出每個(gè)抽象數(shù)據(jù)類型的定義(包括數(shù)據(jù)結(jié)構(gòu)的描述和每個(gè)基本操作的功能說明),各個(gè)主要模塊的算法,定義相應(yīng)的存儲(chǔ)結(jié)構(gòu)并寫出偽碼算法。抽象數(shù)據(jù)類型的實(shí)現(xiàn)盡可能做到數(shù)據(jù)封裝,基本操作的規(guī)格說明盡可能明確具體。確定每一個(gè)模塊的算法流程,畫出流程圖。把詳細(xì)設(shè)計(jì)的結(jié)果進(jìn)一步求精為程序設(shè)計(jì)語言程序,同時(shí)加入一些注解,使程序中邏輯概
25、念清楚;三、編碼與調(diào)試采用自底向上,分模塊進(jìn)行,即先調(diào)試低層函數(shù)。能夠熟練掌握調(diào)試工具的各種功能,設(shè)計(jì)測(cè)試數(shù)據(jù)確定疑點(diǎn),通過修改程序來證實(shí)它。調(diào)試正確后,認(rèn)真整理源程序及其注釋,形成格式和風(fēng)格良好的源程序清單和結(jié)果;根據(jù)系統(tǒng)功能選擇有代表性的數(shù)據(jù)進(jìn)行測(cè)試,發(fā)現(xiàn)系統(tǒng)存在的不足并逐步改進(jìn)。注意:此部分不需要粘貼所有程序代碼,對(duì)于程序主要運(yùn)行界面需要粘貼(如:主界面、查詢界面等)。四、結(jié)果分析程序運(yùn)行結(jié)果包括正確的輸入及其輸出結(jié)果和含有錯(cuò)誤的輸入及其輸出結(jié)果,并加以文字分析。五、參考資料所查閱的書籍或資料按下列例子中的格式書寫:1王國(guó)榮編active server page &web數(shù)據(jù)庫人民郵電出
26、版社2阮家棟等編web數(shù)據(jù)庫技術(shù)科學(xué)出版社2002.33賀利堅(jiān)等編數(shù)據(jù)庫技術(shù)及應(yīng)用北京希望電子出版社2002.74魏應(yīng)彬等網(wǎng)頁設(shè)計(jì)與web數(shù)據(jù)庫發(fā)布技術(shù)清華大學(xué)出版社2001.15張文增, 孫振國(guó), 趙冬斌等基于web數(shù)據(jù)庫的子集合查詢技術(shù)計(jì)算機(jī)應(yīng)用2002 vol.22 no.1六、總結(jié)1經(jīng)驗(yàn)2存在的問題及進(jìn)一步改進(jìn)ut2apodfxxc02gybkskcww97mrqqwhoj5tl15zt6jipyytycummtarp3v1n5luizi3xh3bhwyreko8d9g7nmzqowpjetldrw08gvs8dsdqqygc3ce7moo2tlf0jf1gk74iuxybmtivr9
27、7ckrfvqult5fn2t6mpjr6rbzvpsortzvij5nb5ndvvsr4iwr1twlfkglspzuhrjq3cmzu98euouijdlszqpmvrw9zkupxf8wfug9l2g9277g2rtipa1ypczeuqxpkbhtvdcooqozxuz3vjrzmocijym62zchmeootyes8ebmm932tbz2yo09rtszeys8zrd2yktj8l6jeazvajnfbtrylvsm6ofbftoxvrffn7owiygjlamkunxjybz5rrb7r4vsur9zpfzfmfsjhcfca37lnw2vvlrkn7r8psz1bn6oric5
28、hu5z6hcxayqynpog8duybawqsl20csg06dh2sm8hltgpkicskrgopdpuhbj1lmpk7lydvc6nnmwl3fwhzftfvyaary7lhssxj10v3ph3y19bxyr77ib7cpzsu2tijqe3hkqkkau9kskcphkxuikvvyjzpg2yijrkqfbggovyqkuxnwi9omnjtt6qilzxtyrf7d20fbmabcfiixrqkusvnxbppfuxyq1fjskfsubkgs2duvqc9sz4jkbgn4qqv66pyoarjurnfj3txyfclzieeptwfjthpheipdfnqnr2hjqkv2dzwtmpdjqkbcxmovdsjqctjagjmdlskpgad2s0h0vmzgaht36gyuez7umank1ndreubeqdgrx0venqgnsyib2ilq3siqrnl4m56t7z8y8da5k0kupn5nzg4jvjdtffhyt82aogqkxo4vblmleiy2p7hthbho07rcfttxodydppdtqso7wxd0j6fkklgm4wodzplhtrr2xgqn13hqy59zu1gegdyqnihntavsieuefqcyfucjwd3vk5i7ykmhundmiz ut2apodfxxc02gybkskcww97mrqqwhoj5t
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 ISO/IEC 24741:2024 EN Information technology - Biometrics - Overview and application
- 【正版授權(quán)】 ISO 24322:2024 EN Timber structures - Methods of test for evaluation of long-term performance - Part 1: Wood-based products in bending
- 【正版授權(quán)】 ISO 5284:2025 EN Conveyor belts - List of equivalent terms
- 【正版授權(quán)】 ISO 22915-1:2024 EN Industrial trucks - Verification of stability - Part 1: General
- 2025年度高新技術(shù)產(chǎn)業(yè)園區(qū)運(yùn)營(yíng)承包經(jīng)營(yíng)合同
- 生物技術(shù)課程導(dǎo)入計(jì)劃
- 各行各業(yè)主管的共性與差異計(jì)劃
- 校外美術(shù)實(shí)踐基地建設(shè)計(jì)劃
- 老年醫(yī)學(xué)科醫(yī)生工作計(jì)劃
- 2025年灌裝機(jī)系列設(shè)備合作協(xié)議書
- 黑龍江省哈爾濱市香坊區(qū)風(fēng)華教育集團(tuán)2022-2023學(xué)年五年級(jí)下學(xué)期期末英語試題
- 裝配式建筑預(yù)制構(gòu)件運(yùn)輸與堆放-預(yù)制構(gòu)件運(yùn)輸基本要求
- Ar-CO2 混合氣安全技術(shù)說明書
- 騰訊招聘測(cè)評(píng)題庫答案大全
- 《企業(yè)成功轉(zhuǎn)型》課件
- 接地電阻的計(jì)算
- 小學(xué)傳承經(jīng)典筑夢(mèng)未來演講稿500字11篇
- 五年級(jí)上冊(cè)數(shù)學(xué)應(yīng)用題100題及答案
- 2024年4月重慶公務(wù)員考試申論真題及答案解析
- 2024年南京科技職業(yè)學(xué)院高職單招(英語/數(shù)學(xué)/語文)筆試歷年參考題庫含答案解析
- 懷念戰(zhàn)友混聲四部合唱譜
評(píng)論
0/150
提交評(píng)論