向高手求助
以下是小弟编写的一段代码,编译老不能通过,并提示F:\TOOLS\5566\5566.cpp(52) : error C2360: initialization of 'dw' is skipped by 'case' label
F:\TOOLS\5566\5566.cpp(51) : see declaration of 'dw'并且都是这样的错误提示,往高手进来帮,忙解答一下,小弟先谢过了
float xuesheng::statidtic()
{ char chengji;
cin>>chengji;
int dw=0;int cw=0;int mw=0 ; int ew=0; int sw=0;int tw=0; int pw=0;
switch (chengji){
case 'd1': for(int dw=0;dw<=count;dw++) { float dm; dm+=elec; float elecp; elecp=dm/count;return elecp;};break;
case 'c1':for(int cw=0;cw<=count;cw++) {float cm; cm+=c_prog; float c_progp; c_progp=cm/count;return c_progp;};break;
case 'm1':for(int mw=0;mw<=count;mw++) {float mm; mm+=media; float mediap; mediap=mm/count; return mediap;};break;
case 'e1':for (int ew=0;ew<=count;ew++) {float em; em+=eng; float engp ; engp=em/count; return engp;};break;
case 's1':for (int sw=0;sw<=count;sw++) {float sm; sm+=math;float mathp; mathp=sm/count; return mathp;};break;
case 't1':for (int tw=0;tw<=count;tw++) {float tm; tm+=sport;float sportp; sportp=tm/count; return sportp;};break;
case 'p1':for (int pw=0;pw<=count;pw++) { float pm; pm+=polity;float polityp; polityp=pm/count; return polityp;};break;
defaut:cout<<"没有这个成绩,请核实后重新输入";}
}