静态变量

#include<stdio.h>
void synthesis(void);
int main() {
	int count,number;
	for( count=1,number=1;count<=3,number<=3;count++,number++)
	{
		printf("here is the most %d\n", count);
		synthesis();
	}

}
void synthesis(void) {
	int fade = 1;
	static int stay = 1;//创建一个不变的变量
	printf("%d and %d\n", fade++, stay++);//先用后加
	printf("%d or %d\n", ++fade, ++stay);//先加后用
}

here is the most 1

1 and 1

3 or 3

here is the most 2

1 and 3

3 or 5

here is the most 3

1 and 5

3 or 7

输出答案

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务