namespace myNum
{
int x = 105;
}
int main()
{
bool isFlag = false;
if(myNum::x % 2 == 0)
{
//改變狀態位的值,使其為false
isFlag = false;
}
else
{
isFlag = true;
}
if(isFlag=true)
{
cout<<"變量是奇數"<<endl;
}
else
{
cout<<"變量是偶數"<<endl;
}
return 0;
}
{
int x = 105;
}
int main()
{
bool isFlag = false;
if(myNum::x % 2 == 0)
{
//改變狀態位的值,使其為false
isFlag = false;
}
else
{
isFlag = true;
}
if(isFlag=true)
{
cout<<"變量是奇數"<<endl;
}
else
{
cout<<"變量是偶數"<<endl;
}
return 0;
}
using namespace std; //后面的函數就可以直接調用std
優點:避免了重復使用std::cout 等這樣的函數前面加上使用函數相應的域名
優點:避免了重復使用std::cout 等這樣的函數前面加上使用函數相應的域名
2017-09-15
#include<iostream>
#include<stdlib.h>
using namespace std; //關于這里,且聽下回分解
int main()
{
printf("Hello imooc"); //在此填寫我們的開篇Hello imooc
return 0;
}
#include<stdlib.h>
using namespace std; //關于這里,且聽下回分解
int main()
{
printf("Hello imooc"); //在此填寫我們的開篇Hello imooc
return 0;
}
2017-09-15
#include<iostream>
#include<stdlib.h>
using namespace std; //關于這里,且聽下回分解
int main()
{
printf("Hello imooc"); //在此填寫我們的開篇Hello imooc
return 0;
}
#include<stdlib.h>
using namespace std; //關于這里,且聽下回分解
int main()
{
printf("Hello imooc"); //在此填寫我們的開篇Hello imooc
return 0;
}
2017-09-15
一直說我cin和cout,還有system沒有聲明標識符
#include<iostream>
#include <stdlib.h>
#include"stdafx.h"
int main(void)
{
int arr1[4] = { 3,5,1,7 };
bool isMax = false;
cin >> isMax;
cout << getMaxOrMin(arr1, 4, isMax) << endl;
system("pause");
return 0;
}
#include<iostream>
#include <stdlib.h>
#include"stdafx.h"
int main(void)
{
int arr1[4] = { 3,5,1,7 };
bool isMax = false;
cin >> isMax;
cout << getMaxOrMin(arr1, 4, isMax) << endl;
system("pause");
return 0;
}
#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