為什么結果中輸入除過0之外的其他數顯示都是true?
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(void)
{
??? cout<<""<<endl;
??? int x=0;
??? cin>>x;
??? cout<<oct<<x<<endl;
??? cout<<dec<<x<<endl;
??? cout<<hex<<x<<endl;
??? cout<<""<<endl;
??? bool y=false;
??? cin>>y;
??? cout<<boolalpha<<y<<endl;
system("pause");
return 0;
}
2016-09-17
C++中,定義0是false,非0是true
2016-09-13
代碼沒有錯,可能是軟件的原因吧!在我上面就不會出現你說的那種情況,你試試把?cout<<""<<endl;中間寫一些字,不要那么懶,,,希望有幫助
2016-09-13
buzhidao