#include<stdio.h>
int counter(int i){
static int count=0;//编译时只运行一次
count=count+i;
return count;
}
main()
{
int i,j;
for(i=0;i<5;i++)
{
j=counter(i);
printf("i:%d,j:%d\n",i,j);
}
}
时间: 2024-11-03 05:35:31
#include<stdio.h>
int counter(int i){
static int count=0;//编译时只运行一次
count=count+i;
return count;
}
main()
{
int i,j;
for(i=0;i<5;i++)
{
j=counter(i);
printf("i:%d,j:%d\n",i,j);
}
}