国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

第二章 開始學習C++

2019-11-06 06:22:51
字體:
來源:轉載
供稿:網友

2.7編程練習

開始進行C++學習,希望能堅持下來,完整的過完一遍C++PRimer Plus(第五版) 一遍。同時開始寫屬于自己的技術博客,+.+,記錄自己再技術路上的成長,也希望我的心得體會能幫助到更多的人,找到志同道合的小伙伴。 另外,題目都沒有寫全,書本上有,這里只提了一個大概。懶,囧...

第一題:顯示姓名地址。

include<iostream>int main(void){ using namespace std; cout<<"姓名:杰尼西斯。/n"; cout<<"地址:陜西,西安,雁塔區。/n"; //cin.get(); cin.get(); return 0;}

結果顯示2.1

第二題:輸入距離,單位浪,轉換為碼。

#include<iostream>int main(void){ using namespace std; int a; cout << "請輸入浪數:"; cin >> a; cout << a<<"浪="<<a*220<<"碼/n/n"; cin.get(); return 0;}

結果顯示2.2

第三題:編寫程序,包含三個用戶自定義函數,滿足題目規定的輸出。

#include<iostream>#include<string>using namespace std;string str1(void);void str2(void);int main(void){ using namespace std; cout << str1() <<endl; cout << str1() << endl; str2(); cout << endl; str2(); cin.get(); return 0;}string str1(void){ using namespace std; string a; a="Three blind mice"; return a;}void str2(void){ cout << "See how they run";}

結果顯示2.3

第四題:編寫程序,調用一個自定義函數,進行溫度轉換。

#include<iostream>double trans(double);int main(void){ using namespace std; double a; cout << "Please enter a Celsius value:"; cin >> a; cout << a << " degrees Celsius is " << trans(a) << " degrees Fahrenheit./n"; getchar(); getchar(); return 0;}double trans(double a){ return 1.8*a + 32.0;}

結果顯示2.4

第五題:編寫程序,調用一個自定義函數,進行光年轉換。

#include<iostream>double trans(double);int main(void){ using namespace std; double a; cout << "Enter the number of liget years:"; cin >> a; cout << a << " liget years = " << trans(a) << " astronomical units./n"; cin.get(); getchar(); return 0;}double trans(double a){ return a*63240;}

結果顯示2.5

第六題:編寫程序,讓用戶輸入時間,調用一個自定義void函數,顯示時間。

#include<iostream>void trans(double a, double b);int main(void){ using namespace std; double a,b; cout << "Enter the number of hours:"; cin >> a; cout << "Enter the number of minutes:"; cin >> b; trans(a,b); cin.get(); getchar(); return 0;}void trans(double a, double b){ using namespace std; cout<<"Time: "<<a<<":"<<b<<endl;}

結果顯示2.6

第二章編程練習結束,都是基礎內容。^.^


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 呼伦贝尔市| 井冈山市| 凤台县| 阳西县| 友谊县| 舞阳县| 靖江市| 临城县| 婺源县| 榆中县| 堆龙德庆县| 通州市| 宝丰县| 赤壁市| 罗山县| 鞍山市| 麻江县| 株洲县| 安国市| 屏东县| 潼南县| 乌鲁木齐县| 莱西市| 平安县| 杭锦后旗| 京山县| 北流市| 沙田区| 颍上县| 南木林县| 体育| 白沙| 扎囊县| 溧水县| 娄烦县| 临海市| 西乌| 八宿县| 四子王旗| 武宣县| 临高县|