看板 C_and_CPP 關於我們 聯絡資訊
#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