C++的switch問題?
#include <iostream>
using namespace std;
int main()
{
int rs;
double a,b,c,d,e;
a=b=c=d=e=0;
cout<<"輸入產品編號1到5,並顯示價錢;CTRL+Z顯示所有物品總和"<<endl;
while((rs=cin.get())!=EOF)
{
switch(rs)
{
case 49:cout<<"2.98"<<endl;
++a;
break;
case 50:cout<<"4.50"<<endl;
++b;
break;
case 51:cout<<"9.98"<<endl;
++c;
break;
case 52:cout<<"4.49"<<endl;
++d;
break;
case 53:cout<<"6.87"<<endl;
++e;
break;
case '\n':
case '\t':
case ' ':
break;
default:
cout<<"無此物品"<<endl;
break;
}
}
cout<<"總共是"<<a*2.98+b*4.50+c*9.98+d*4.49+e*6.87<<endl;
system ("pause") ;
return 0 ;
}
∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼
請問為什麼沒有打紅色部份的程式
switch的時候就會一直跑到default
麻煩各位了~~
|