C++
有錯請幫忙指正
#include<iostream>
using namespace std;
int main(){
int la=0;
int lb=0;
int lc=0;
while (true) {
long sal;
cout << "請輸入薪資(結束請輸入-1): ";
cin >> sal;
if (sal == -1) {
break;
}
if (sal < 0) {
cout << "輸入錯誤" << endl;
} else if (sal > 100000) {
lc += 1;
} else if (sal > 35000 && sal <= 100000) {
lb += 1;
} else {
la += 1;
}
}
cout<<"A等級有"<<la<<"人"<<endl;
cout<<"B等級有"<<lb<<"人"<<endl;
cout<<"C等級有"<<lc<<"人"<<endl;
return 0;
}
輸出: