Mottman: Thanks for your advise, but wat i want is others than the character i put into the
switch, it will cout zone 4, if i key in others.So, how to switch all the others in a case so
it will show zone 4?
Kyon: Actually this is my past year paper in which the question ask us to change the if and else if
to the switch case.
Case is not superior to else if, in fact, it's worse in most cases (pun not intended), since case will not allow you to check non-const values. (Like objects or other values that are not literals.) In your case, it's not really a good idea to use switches. Furthermore, in your code example, you were coutting "zone = 1", "zone = 2", etc, and you had an integer called zone. I don't know if you expect the program to do something with that value, but it won't. I fixed this in my example too.
Shortly put, it's impossible to check for non-constant values in a case-statement.