#include <iostream>
#include <stdlib.h>
using namespace std;
namespace myNum //填寫命名空間的關鍵字
{
int x = 105;
}
if(isFlag)
{
// 如果狀態位的值為true,則打印變量x是奇數
cout<<myNum::x<<"是奇數"<<endl;
}
else
{
// 如果狀態位的值為false,則打印變量x是偶數
cout<<myNum::x<<"是偶數"<<endl;
}
#include <stdlib.h>
using namespace std;
namespace myNum //填寫命名空間的關鍵字
{
int x = 105;
}
if(isFlag)
{
// 如果狀態位的值為true,則打印變量x是奇數
cout<<myNum::x<<"是奇數"<<endl;
}
else
{
// 如果狀態位的值為false,則打印變量x是偶數
cout<<myNum::x<<"是偶數"<<endl;
}
簡潔版
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(void)
{
cout << "請輸入一個整數以及一個布爾值(0、1)" << endl;
int x = 0;
bool y = false;
cin >> x >> y;
cout << oct << x << endl << dec << x << endl << hex << x << endl;
cout << boolalpha << y << endl;
system("pause");
return 0;
}
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(void)
{
cout << "請輸入一個整數以及一個布爾值(0、1)" << endl;
int x = 0;
bool y = false;
cin >> x >> y;
cout << oct << x << endl << dec << x << endl << hex << x << endl;
cout << boolalpha << y << endl;
system("pause");
return 0;
}
2017-09-02
啊一股 這里是不是有點故障啊,怎樣輸都錯。endl沒什么錯的,它是end line 縮寫,作用是換行,跟 \n一樣。
然后頭文件如果寫成#include<iostream.h>的話就不用再寫 using namespace std;了
然后頭文件如果寫成#include<iostream.h>的話就不用再寫 using namespace std;了
2017-09-01
最新回答 / ER木偶呀
不對吧在上面代碼里有isFlag的狀態所以才能運行 樓上沒看懂代碼吧!? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ...
2017-08-30