变量作用域
#include<iostream>
void print();
int main()
{
char a=0;
for(a=0;a<20;a++)
print();
return 0;
}
void print()
{
static int x=0;//静态变量声明,其值会一直保留
x++;
std::cout<<x<<std::endl;
}#include<iostream>
void print();
int main()
{
char a=0;
for(a=0;a<20;a++)
print();
return 0;
}
void print()
{
static int x=0;//静态变量声明,其值会一直保留
x++;
std::cout<<x<<std::endl;
}讲到函数就可以讲讲局部变量和全局变量了,什么是局部变量呢?什么又是全局变量? #include <iostream> using namespace std; int x,y,z;//x,y,z是全局变量 i...
假如我让你计算从1加到500,你会怎么计算,用累加公式?假如,没有累加公式,你只能从1挨个往上加,用计算机能不能实现这一一件事呢?4种方法:1、#include <iostream> using namespace std; int main(...
本教程内所有代码均不包含运行的结果,请大家先看https://www.myfpga.cn/?id=9https://www.myfpga.cn/?id=11...
#include<iostream> using namespace std; int main() { int x=0; for(x=0;x<10;x++) { if(x==3) break;...
/*C风格字符串的声明和使用 #include<cstdio.h> int main() { char x[]={'H','e','l','l','o','&...
#include<iostream> using namespace std; struct books{ char name[10]; int num; float price; }book; int&nb...