我有幾題在書中看到幾個練習題不會作
請幫我做做看
2007-04-14 18:11:06 · 2 個解答 · 發問者 文廷 1 in 電腦與網際網路 ➔ 程式設計
1. 輸入台斤數,求公斤數(1台斤=0.6公斤)
2. 請輸入某人國文,英文及數學的分數,求總分,平均
3. 輸入x與y若x > y 則設z=x - y, 若x <= y則設z= y - x,最後輸出x,y及z的值
請幫我做做看
2007-04-14 18:12:41 · update #1
不好意思
你寫的我有點看不懂
可不可以分
第一題是甚麼
第二題是甚麼
第三題是甚麼
而且不用全部用在一起
2007-04-14 19:44:29 · update #2
========================================
1.輸入台斤求公斤數 比率1:0.6
========================================
#include
#include
int main(void)
{
int i=0;
cout<<"輸入台斤=";
cin>>i;
cout<<"============================\n";
cout<
system ("pause");
}
========================================
2.國、英、數成績加總及平均計算
========================================
#include
#include
int main (void)
{
int i=0,x=0,y=0,sum;
cout<<"輸入國文分數=";
cin>>i;
cout<<"輸入英文分數=";
cin>>x;
cout<<"輸入數學分數=";
cin>>y;
sum=i+x+y;
cout<<"總分="<
}
========================================
3.輸入x與y 列出 z=x與y中(大值-小值)
========================================
#include
#include
int main (void)
{
int x=0,y=0,z=0;
cout<<"輸入x=";
cin>>x;
cout<<"輸入y=";
cin>>y;
if (x>y)
{
z=x-y;
cout<<"x="<
else if(x<=y)
{
z=y-x;
cout<<"運算式為z=y-x"
<<"\nx="<
system ("pause");
}
有問題可以msn上問我... maskertiti@hotmail.com
若是我了解的領域內我都會盡量回答
加入好友時麻煩告知是知識+的朋友!謝謝
2007-04-14 20:22:40 · answer #1 · answered by 阿志 2 · 0⤊ 0⤋
//Power by Visual Studio 2005
#include
#include
#include
#include
using namespace std;
int main(int argc, char** argv){
//==========START==========//
double tw_kg,ch,en,math,x,y,z;
cout<<"Input Taiwanese Kilogram: ";
cin>>tw_kg;
cout<
cout<<"Kilogram= "<
cout<<"Input Chinese: ";
cin>>ch;
cout<<"Input English: ";
cin>>en;
cout<<"Input Math: ";
cin>>math;
cout<<"Average= "<<(ch+en+math)/3<
cout<<"Input X: ";
cin>>x;
cout<<"Input Y: ";
cin>>y;
z=abs(x-y);
cout<<"X= "<
cout<<"Y= "<
cout<<"Z= "<
//==========END==========//
system("PAUSE");
return EXIT_SUCCESS;
}
2007-04-14 23:40:13 補充:
請勿剪下貼上!
2007-04-14 19:39:51 · answer #2 · answered by Big_John-tw 7 · 0⤊ 0⤋