-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdlib.h> | ||
#include <iostream> | ||
using namespace std; | ||
|
||
//int main(int argc, const char * argv[]) | ||
int main(int argc, char * argv[]) | ||
{ | ||
cout << "argc count is:" << argc << endl; | ||
cout << "argv value is:" << argv[0] << endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <stdlib.h> | ||
#include <iostream> | ||
using namespace std; | ||
|
||
// 定义第一个命名空间 | ||
namespace stu | ||
{ | ||
int x (100); | ||
void fun() | ||
{ | ||
cout << "hello world!!!" << endl; | ||
} | ||
} | ||
|
||
// 定义第二个命名空间 | ||
namespace myNum | ||
{ | ||
int x; | ||
int y; | ||
|
||
int setNum() | ||
{ | ||
cout << "请输入整型:"; | ||
cin >> x >> y; | ||
|
||
cout << "Y is:" << y << endl; | ||
|
||
return x; | ||
} | ||
} | ||
|
||
// 定义主入口 | ||
int main() | ||
{ | ||
bool flag (false); | ||
int b (10); | ||
cout << flag << " == " << stu::x << endl; | ||
|
||
stu::fun(); | ||
|
||
myNum::setNum(); | ||
|
||
bool isFlag = false; | ||
|
||
if(myNum::x % 2 ==0) | ||
{ | ||
isFlag = false; | ||
} | ||
else | ||
{ | ||
isFlag = true; | ||
} | ||
|
||
if(isFlag) | ||
{ | ||
cout << myNum::x << " 是奇数" << endl; | ||
} | ||
else | ||
{ | ||
cout << myNum::x << " 是偶数" << endl; | ||
} | ||
return 0; | ||
} | ||
|
||
/* vim: set ts=4 sw=4 sts=4 tw=100 */ |