#include<iostream>
using namespace std;
int fun()
{
static int x=0; // static静态局部变量:只初始化1次
x++;
return x;
}
int main()
{
int i;
for(i=0;i<10;i++)
{
cout<<fun()<<"\t";
}
cout<<endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: