看看的C程序
vector<int> num;
int temp=0;
int max=0,min=0;
while(cin>>temp)
{num.push_back (temp);
sort(num.begin (),num.end ());
max=num[num.size ()-1];
min=num[0];
cout<<"the temp is:"<<temp<<endl;
cout<<"the min is:"<<min<<endl;
cout<<"the max is:"<<max<<endl;
if(temp<min)
cout<<"the samlest so far:"<<temp<<'\n';
else if(temp>max)
cout<<"the largest so far:"<<temp<<'\n';
}
如上:程序的意思很明了,前面temp、min和max的值都是的。但是程序始都不入if分支,不知是什么原因?求解。
[解决办法]
1、temp==min Or temp==max
即使为中间值 temp不会小于min;temp也不会大于max
[解决办法]
中情只出在入第一的候啊,入的多的候,后面的情入if判才啊。
[解决办法]
该回复于2011-11-24 13:37:42被版主删除
[解决办法]
lz 逻辑混乱
[解决办法]
temp与min,max二个值的关系只能是temp=min,temp=max,不可能出现temp<min,temp>max情况,当然不会进入if判断,你自己输入几个数据看看就知道了,temp和min,max的关系