作者ichen0128 (真想聊聊天)
看板C_and_CPP
標題[問題] 分數範圍的問題 ???
時間Mon Feb 9 22:04:56 2009
#include <iostream>
using namespace std ;
int main()
{
double a,b,c,d ;
start : cout << "國文分數:" ;
cin >> a ;
cout << "英文分數:" ;
cin >> b ;
cout << "數學分數:" ;
cin >> c ;
if( 0>a | a>100 )
cout << "輸入分數範圍錯誤" ;
goto start ;
if (0>b | b>100 )
cout << "輸入分數範圍錯誤" ;
goto start ;
if( 0>c | c>100)
cout << "輸入分數範圍錯誤" ;
goto start ;
d=a* 0.2 + b* 0.4 +c*0.4 ;
cout << "加權分數" << d << endl ;
system ("pause") ;
return 0 ;
}
如何將 a,b,c 三個變數 的範圍設定在0到100之間 ???
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.165.136.193
推 ilway25:| 不是 || 02/09 22:09
→ ichen0128:你的意思是說 or不能用在if裡面嗎 02/09 22:12
→ eai:||才是邏輯上的or,|這個是位元運算子的or 02/09 22:16