Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

编写函数,使其在第一次调用时返回 0,然后再次调用时按顺序产生正整数(即 返回其当前的调用次数)。

$
0
0
int count_return( )
{
	static int counts = 0;
	return counts++;
}

int main( int argc, char **argv ) //argc用于传递argv中字符串的个数, argv是一个C风格字符串数组
{
	for( int i = 0; i < 10; i++ )
	{
		cout << count_return();
	}
	
	return 0;
}

作者:huangbangqing12 发表于2013-4-2 20:22:52 原文链接
阅读:43 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>