using namespace std;
namespace myNum
{int x = 56934528762;
}
int main()
{
bool isFlag ;
if(myNum::x % 2 == 0)
{
isFlag=false;
}
else
{
isFlag=true;}
if(isFlag==0)
{
cout<<"x是偶數";
}
else
{
cout<<"x是奇數";
}
return 0;
}
故意用bool拐了一個彎
namespace myNum
{int x = 56934528762;
}
int main()
{
bool isFlag ;
if(myNum::x % 2 == 0)
{
isFlag=false;
}
else
{
isFlag=true;}
if(isFlag==0)
{
cout<<"x是偶數";
}
else
{
cout<<"x是奇數";
}
return 0;
}
故意用bool拐了一個彎
#include <stdlib.h>
int main(void)
{
system("pause");
return;
}
會提示報錯,錯誤內容如下:
錯誤 1 error C2561:
“main”: 函數必須返回值
c:\users\吳吉男\desktop\c++\test100\test100\test.cpp
7 1 test100
int main(void)
{
system("pause");
return;
}
會提示報錯,錯誤內容如下:
錯誤 1 error C2561:
“main”: 函數必須返回值
c:\users\吳吉男\desktop\c++\test100\test100\test.cpp
7 1 test100
2016-08-27
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
system("pause");
return;
}
#include <stdlib.h>
int main(void)
{
system("pause");
return;
}
2016-08-27
已采納回答 / s_word
第一個問題,如果fun2沒有定義在命名空間B里面,則被調用時當然不用using namespace B.但他已經被定義在B命名空間里了,則被調用時,必須顯式的用B::fun2,或者用using namespaced B的方式。你試試在文件頭只寫了#include <iostream>,但是不寫using namespace std,cin和cout能否直接使用?顯然不能。如果寫成std::cin和std::cout,則可以正常使用。為什么?在文件里cin和cout是獨立出現沒有重復的,但若不聲...
2016-08-26
int main(int argc, char* argv[])
{
cout << "請輸入一個整數" << endl;
int i;
cin >> i;
cout << "八進制:" << oct << i << ",";
cout << "十六進制:" << hex << i << ",";
cout << "十進制:" << i << ",";
cout << "布爾值:" << boolalpha << (bool)i << endl;
cin.get();
cin.get();
return 0;
}
{
cout << "請輸入一個整數" << endl;
int i;
cin >> i;
cout << "八進制:" << oct << i << ",";
cout << "十六進制:" << hex << i << ",";
cout << "十進制:" << i << ",";
cout << "布爾值:" << boolalpha << (bool)i << endl;
cin.get();
cin.get();
return 0;
}
2016-08-22