摘要: 1:静态变量static可以分为静态局部变量和静态全局变量,静态局部变量的值在函数调用结束后不消失,静态全局变量只能在本源文件中使用。 静态变量属于静态存储方式,它具有以下特点: (1)静态变量在函数内定义,在程序退出时释放,在整个程序的运行期间都不释放,也就是说它的生存周期为整个源程序。 (2)静 阅读全文
posted @ 2017-09-14 14:43 一串字符串 阅读(1096) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.9.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> using namespace std; void main() { int i,j,k;//此k的生命周期是整个主函数 cout <<"inp 阅读全文
posted @ 2017-09-14 14:26 一串字符串 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.8.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int name = 0; int main() { int name = 3; cout<<"局部 阅读全文
posted @ 2017-09-14 14:16 一串字符串 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.7.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int globalCount = 33; //全局变量,全局变量的作用域为整个cpp文件 int 阅读全文
posted @ 2017-09-14 13:59 一串字符串 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.6.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int Add(int x ,int y) //定义第一个重载函数 { cout << "int a 阅读全文
posted @ 2017-09-14 12:45 一串字符串 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.5.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; typedef unsigned int UINT; //自定义类型 long Fac(const 阅读全文
posted @ 2017-09-14 11:02 一串字符串 阅读(1100) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.4.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; long Fac(int n) { if(n==0) return 1; else return n 阅读全文
posted @ 2017-09-14 10:23 一串字符串 阅读(881) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.3.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; long lCount;//第几次移动 void move(int n,char x,char y, 阅读全文
posted @ 2017-09-14 10:04 一串字符串 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.2.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using std::cout; using std::endl; bool Less(int a,int b = 1) //b具有默认值1 阅读全文
posted @ 2017-09-14 09:38 一串字符串 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 4.1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void ShowMessage(); //函数声明语句 void ShowAge(); //函数声 阅读全文
posted @ 2017-09-14 09:31 一串字符串 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.25.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int main(int argc, _TCHAR* argv[]) { //若直接使用for循环 阅读全文
posted @ 2017-09-14 09:11 一串字符串 阅读(562) 评论(0) 推荐(0) 编辑
摘要: 1:运行代码: // 3.24.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; int main(int argc, _TCHAR* argv[]) { do{ int num, 阅读全文
posted @ 2017-09-14 09:01 一串字符串 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.23.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iomanip> #include <iostream> using namespace std; void main(void) { int i,j; i=1 阅读全文
posted @ 2017-09-14 08:54 一串字符串 阅读(386) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.22.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int i, j, k; for (i = 1; i <= 5; i+ 阅读全文
posted @ 2017-09-14 08:40 一串字符串 阅读(1889) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.21.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int ivar = 0 ; //定义一个整型变量,初始化为0 int 阅读全文
posted @ 2017-09-14 08:25 一串字符串 阅读(335) 评论(0) 推荐(0) 编辑
摘要: 1:continue不是立即跳出循环体,而是跳过本次循环结束前的语句,回到循环的条件测试部分。代码如下: // 3.20.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void 阅读全文
posted @ 2017-09-13 16:27 一串字符串 阅读(792) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.19.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int i,n,sum; sum=0; cout<< "请输入10个整 阅读全文
posted @ 2017-09-13 16:21 一串字符串 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.18.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int sum=0; int i; for(i=1;i<=10;i++ 阅读全文
posted @ 2017-09-13 16:14 一串字符串 阅读(2141) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.17.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int i=0,j=0; cout << "执行while前j=" < 阅读全文
posted @ 2017-09-13 16:08 一串字符串 阅读(387) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.16.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int i=0,j=0; cout << "before do_whi 阅读全文
posted @ 2017-09-13 16:04 一串字符串 阅读(430) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.15.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int sum=0,i=1; do { sum=sum+i; i++; 阅读全文
posted @ 2017-09-13 15:59 一串字符串 阅读(816) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.14.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int sum=0,i=1; while(i<=10) { sum=s 阅读全文
posted @ 2017-09-13 15:53 一串字符串 阅读(2896) 评论(0) 推荐(0) 编辑
摘要: 1:不加break,会依次运行下面的语句,代码如下: // 3.13.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { cout<<"输入一个1-7范围 阅读全文
posted @ 2017-09-13 15:46 一串字符串 阅读(845) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.12.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { cout<<"输入一个A-D范围内的大写字母作为成绩评价"<<endl 阅读全文
posted @ 2017-09-13 15:42 一串字符串 阅读(448) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.11.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { cout<<"输入一个A-D范围内的大写字母作为成绩评价"<<endl 阅读全文
posted @ 2017-09-13 15:38 一串字符串 阅读(591) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.10.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include <iomanip> using namespace std; void main() { cout<<"输入一个A-D范围 阅读全文
posted @ 2017-09-13 15:02 一串字符串 阅读(403) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.9.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> using namespace std; void main() { int iInput; cout << "输入一个整数" << endl; 阅读全文
posted @ 2017-09-13 14:46 一串字符串 阅读(317) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.8.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> using namespace std; void main() { int iInput; cout << "输入一个整数" << endl; 阅读全文
posted @ 2017-09-11 20:23 一串字符串 阅读(1189) 评论(0) 推荐(0) 编辑
摘要: 1:条件运算符是一个三目运算符,能像判断语句一样完成判断。例如: max=(iA>iB) ? iA:iB; 意思是先判断iA是否大于iB,如果是,则max取iA的值,如果不是则取iB的值。 如果没有前边的max,那么就是先判断iA是否大于iB,如果是,就运行iA,如果不是则运行iB。 2:代码如下: 阅读全文
posted @ 2017-09-11 20:19 一串字符串 阅读(1426) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.6.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int iYear; cout << "请输入年份" << endl; 阅读全文
posted @ 2017-09-11 20:02 一串字符串 阅读(844) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.5.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int iYear; cout << "请输入年份" << endl; 阅读全文
posted @ 2017-09-11 19:54 一串字符串 阅读(2173) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.4.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { cout<<"输入成绩"<<endl; int iInput; cin 阅读全文
posted @ 2017-09-11 19:40 一串字符串 阅读(1082) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.3.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int iInput; cout << "输入一个整数:" << end 阅读全文
posted @ 2017-09-11 19:36 一串字符串 阅读(630) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.2.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int iInput; cout<<"大于90为优秀成绩"<<endl; 阅读全文
posted @ 2017-09-11 19:32 一串字符串 阅读(473) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 3.1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int iInput; cout << "输入一个整数" << endl 阅读全文
posted @ 2017-09-11 19:29 一串字符串 阅读(627) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 2.17.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> using namespace std; void main() { float i, j; int k; i = 60.25; j = 20 阅读全文
posted @ 2017-09-11 19:09 一串字符串 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 2.16.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> using namespace std; void main() { double result; char a='k'; int b=10; 阅读全文
posted @ 2017-09-11 19:05 一串字符串 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 2.15.cpp : 定义控制台应用程序的入口点。 #include "stdafx.h" #include<iostream> using namespace std; void main() { int a=4,b=6,c=8,res1,res2; res1=a,res2= 阅读全文
posted @ 2017-09-11 18:59 一串字符串 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 2.14.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { long nWord=0x12345678;//长整形,十六进制输入 阅读全文
posted @ 2017-09-11 18:35 一串字符串 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 2.13.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> using namespace std; void main() { int a=0x40,b; b=a<<1;//左移1位 cout << 阅读全文
posted @ 2017-09-11 16:53 一串字符串 阅读(228) 评论(0) 推荐(0) 编辑