爲什麼我的第一個if語句的工作,但我的其他if語句不?只希望有人能看到我可能會失蹤的東西。當我輸入800到1800之間的代碼時,代碼仍然正常,但是當我輸入600時,它會跳轉到我以非法格式輸入的其他語句。爲什麼我的第一個if語句的工作,但我的其他if語句之後,在沒有工作
if ((time_start >= 800) && (time_start <= 1800))
{
cout << "How many minutes did your call last? ";
cin >> minutes;
cost = minutes * 0.40;
cout << setprecision(2) << fixed << cost;
system("pause");
keepgoing = false;
}
else if ((time_start < 800) && (time_start > 1800))
{
cout << "How many minutes did your call last? ";
cin >> minutes;
cost = minutes * 0.25;
cout << setprecision(2) << fixed << cost;
system("pause");
keepgoing = false;
}
你別的定義不能成功,因爲TIME_START必須小於800和大於1800,這是不可能的。 – MildWolfie
謝謝大家!我會標記答案! – Mofayew
@Mofayew,不,你不能標記所有的人所接受,所以你必須明智地選擇:P – ForceBru