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

首頁 > 學院 > 開發設計 > 正文

第三章 處理數據

2019-11-06 06:21:08
字體:
來源:轉載
供稿:網友

第三章 處理數據

第一題:用戶輸入身高,單位英寸,轉換成幾英寸幾英尺輸出。并用下劃線提示輸入位置,用const符號常量表示轉換因子。

#include<iostream>using namespace std;int main(void){ const double a = 0.0833; cout << "Enter your height in inch:___" << "/b/b/b"; int height_inch; cin >> height_inch; int feet; double inch; feet = int(height_inch*a); inch = height_inch - feet/a; cout << "/nYour height is : " << feet << " feet ," << inch << " inch. "; getchar(); cin.get(); return 0;}

結果顯示3.1

ps:題目要求用幾英寸幾英寸表示,不是分別表示英尺的整數和小數部分

第二題:用戶以幾英尺幾英寸形式輸入身高,并以磅數輸入其體重,使用三個變量來存儲,最后計算BMI:體重(千克)除以身高(米)的平方。用符號常量表示各種轉換因子。

#include<iostream>using namespace std;int main(void){ cout << "Your height in form of n foot and m inch." << endl; double height_feet, height_inch; cout << "Please enter the foot value :n = "; cin >> height_feet; cout << "Please enter the inch value :m= "; cin >> height_inch; cout << "Your weight is ___ pound." << "/b/b/b/b/b/b/b/b/b/b"; double pound; cin >> pound; const double a = 12; const double b = 0.0254; const double c = 1 / 2.2; double height_meter,tizhong; cout << "You are : " << height_feet*a + height_inch << " inch. /n"; height_meter = (height_feet*a + height_inch)*b; tizhong = pound*c; cout << "Your BMI value is :" << tizhong /height_meter /height_meter<<endl; getchar(); cin.get(); return 0;}

結果顯示2.1

第三題:用戶以度分秒輸入一個維度,轉換成以度顯示。轉換因子以符號常量表示,并對每個輸入量有一個獨立常量存儲

#include<iostream>using namespace std;int main(void){ cout << "Enter a latitude in degrees, minutes,and seconds "<<endl ; cout << "First,enter the degrees: "; double degrees; cin >> degrees; cout << "Next,enter the minutes of arc: "; double minutes; cin >> minutes; cout << "Finally,enter the seconds of arc: "; double seconds; cin >> seconds; const double trans = 60; cout << degrees << "degrees , " << minutes << " minutes , "; cout<< seconds << " seconds = " << degrees + minutes / trans + seconds / trans / trans <<" degrees."<<endl ; getchar(); cin.get();}

結果顯示3.3

第四題:用戶輸入秒數,以符號常量表示每天有多少小時,多少分,多少秒。并轉換為天,小時,分,秒的形式輸出。

#include<iostream>using namespace std;int main(void){ cout << "Enter the number of seconds: "; long seconds; cin>>seconds; const int minutes = seconds / 60; const int hours = minutes / 60; const int days = hours / 24; cout << seconds << " seconds = " << days << " days "; cout << hours%24<<" hours " ; cout << minutes%60 << " minutes "; cout << seconds%60 << " seconds. /n "; getchar(); cin.get(); return 0;}

結果顯示3.4

ps:注意余數的用法

第五題:要求用戶輸入駕駛里程(英里),和耗油量(加侖),計算1加侖能形式的里程。

#include<iostream>using namespace std;int main(void){ cout << "Enter your car miles: " ; double miles; cin >> miles; cout << "Enter your car gas (gallen): "; double gas; cin >> gas; cout << "A gallen ofgas can run " << double(miles)/gas << " miles." << endl; getchar(); getchar(); return 0;}

結果顯示3.5

第六題:要求用戶輸入每100公里的耗油量(升),轉換為每加侖能行駛多少英里。1加侖為3.875升,100公里為62.14英里。

#include<iostream>using namespace std;int main(void){ cout << "Please enter your car cost with Europe. /n"; cout << "100 km cost gas __ L./b/b/b/b/b"; double gas_L; cin >> gas_L; cout << "Your car's cost is " << 62.14/(gas_L/3.875) << " mpg" << endl; getchar(); getchar(); return 0;}

結果顯示3.6

ps:注意單位及顯示風格差異即可。

第三章結束。^.^


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 晋州市| 开封市| 溧阳市| 积石山| 竹北市| 内江市| 三门峡市| 嵊泗县| 文安县| 唐海县| 文山县| 山东省| 丽水市| 仪征市| 隆昌县| 会泽县| 平塘县| 容城县| 尉犁县| 从化市| 海安县| 海南省| 麦盖提县| 建水县| 尚义县| 株洲市| 肃南| 黔东| 海伦市| 唐河县| 黎平县| 九龙城区| 漠河县| 乌兰浩特市| 东辽县| 教育| 雷山县| 金山区| 德清县| 周至县| 晋州市|