摘要:
1:静态变量static可以分为静态局部变量和静态全局变量,静态局部变量的值在函数调用结束后不消失,静态全局变量只能在本源文件中使用。 静态变量属于静态存储方式,它具有以下特点: (1)静态变量在函数内定义,在程序退出时释放,在整个程序的运行期间都不释放,也就是说它的生存周期为整个源程序。 (2)静 阅读全文
摘要:
1:代码如下: // 4.9.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> using namespace std; void main() { int i,j,k;//此k的生命周期是整个主函数 cout <<"inp 阅读全文
摘要:
1:代码如下: // 4.8.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int name = 0; int main() { int name = 3; cout<<"局部 阅读全文
摘要:
1:代码如下: // 4.7.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int globalCount = 33; //全局变量,全局变量的作用域为整个cpp文件 int 阅读全文
摘要:
1:代码如下: // 4.6.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int Add(int x ,int y) //定义第一个重载函数 { cout << "int a 阅读全文
摘要:
1:代码如下: // 4.5.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; typedef unsigned int UINT; //自定义类型 long Fac(const 阅读全文
摘要:
1:代码如下: // 4.4.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; long Fac(int n) { if(n==0) return 1; else return n 阅读全文
摘要:
1:代码如下: // 4.3.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; long lCount;//第几次移动 void move(int n,char x,char y, 阅读全文
摘要:
1:代码如下: // 4.2.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using std::cout; using std::endl; bool Less(int a,int b = 1) //b具有默认值1 阅读全文
摘要:
1:代码如下: // 4.1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void ShowMessage(); //函数声明语句 void ShowAge(); //函数声 阅读全文
摘要:
1:代码如下: // 3.25.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int main(int argc, _TCHAR* argv[]) { //若直接使用for循环 阅读全文
摘要:
1:运行代码: // 3.24.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int main(int argc, _TCHAR* argv[]) { do{ int num, 阅读全文
摘要:
1:代码如下: // 3.23.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iomanip> #include <iostream> using namespace std; void main(void) { int i,j; i=1 阅读全文
摘要:
1:代码如下: // 3.22.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int i, j, k; for (i = 1; i <= 5; i+ 阅读全文
摘要:
1:代码如下: // 3.21.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int ivar = 0 ; //定义一个整型变量,初始化为0 int 阅读全文