他先謝謝你的幫助。我只是在爲我的學校做一件事,而我偶然發現了一個問題。這是一個簡單的賬單計算器,可以區分高級用戶和普通用戶,並根據不同的費率計算您的帳單。我以爲我已經完成了它,但現在我得到這個錯誤。請任何幫助,只是想得到這一切說和做。C++初學者編碼錯誤
調試錯誤!
程序:... \ ConsoleApplication12.exe
模塊:... \ ConsoleApplication12.exe運行時檢查失敗#3 - T的
#include <iostream>
#include<iomanip>
using namespace std;
int main() {
const float Regular = 10;
const float Premium = 25;
const float RRate = .2;
const float DRate = .1;
const float NRate = .05;
int account;
int Rminutes;
int Dminutes;
int Nminutes;
int totalmin;
float Dcharge;
float Ncharge;
float total;
char service;
cout << "Enter the account number\n";
cin >> account;
cout << "Enter the service code\n";
cin >> service;
switch(service)
{case'r':
case'R':
cout << "Please enter the total amount of minutes used\n";
cin >> Rminutes;
if (Rminutes > 50) {
total = (Rminutes - 50)*RRate + Regular;
}
else {
total = Regular;
}
break;
case'P':
case'p':
cout << "Please enter how many minutes were used during the day\n";
cin >> Dminutes;
cout << "Please enter how many minutes were used during the night\n";
cin >> Nminutes;
if (Dminutes > 75) {
Dcharge = (Dminutes - 75)*DRate;
}
if (Nminutes > 100) {
Ncharge = (Nminutes - 100)*NRate;
}
total = Premium + Dcharge + Ncharge;
break;
default:
cout << "Invalid service code\n";
return 1;
break;
}
totalmin = Rminutes + Dminutes + Nminutes;
cout << "Your account number is:" << account;
cout << "Your type of service is:" << service;
cout << "your total minutes used was" << totalmin;
cout << "your bill is" << total;
return 0;
}
您需要將其縮小到[mcve](https://stackoverflow.com/help/mcve)。 – Jason
我只是運行Dev C++上的代碼,它的工作... xD –
該代碼適用於我,輸出是: 您的帳號是:1您的服務類型是:使用的總分鐘數是23您的帳單是10 – anthr