运行结果和我想的不符
初学,求助一个菜鸟问题,先看程序:
#include<iostream.h>
void main()
{ int a,b,c,d;
a=b=c=d=0;
for(int i=0;i<2;i++)
{ cin>>d;
switch(d/2)
{ case0:a+=d;
break;
case1:b+=d;
break;
case2:c+=d;
break;
}
cout<<a<<","<<b<<","<<c<<endl;
}
}
从键盘输入2和3,我想结果应该是0,5,0,可在VC6上运行结果却是0,0,0,大家说为什么?