变量作用域
#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; }
什么是注释呢?这简直是废话,就像您在读书时候做的笔记,复习的时候圈的重点,简单来说,它并不是程序的一部分,但是它可以进行解释程序的行为或者任何想加在程序里面的东西。它的格式就两种,第一种/* 我是注释 我还是注释 &nb...
假如我让你计算从1加到500,你会怎么计算,用累加公式?假如,没有累加公式,你只能从1挨个往上加,用计算机能不能实现这一一件事呢?4种方法:1、#include <iostream> using namespace std; int main(...
#include <iostream>using namespace std;int main(){ cout << "Hello, world!...
#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...