C++ primer(第五版) 练习 6.7 个人code
2014-08-03 22:31
411 查看
C++ primer(第五版) 练习 6.7
题目:
编写一个函数,当它第一次被调用时返回0,以后每次调用返回值加1。
以下是我无脑的答案:
执行结果:
题目:
编写一个函数,当它第一次被调用时返回0,以后每次调用返回值加1。
以下是我无脑的答案:
#include <iostream> using std::cout; using std::cin; using std::endl; int test() { static int jubujingtaibianliang = 0; return jubujingtaibianliang++; } int main() { cout << test() << endl; cout << test() << endl; cout << test() << endl; cout << test() << endl; cout << test() << endl; return 0; }
执行结果:
相关文章推荐
- C++ primer 第五版 中文版 练习 9.47 个人code
- C++ primer 第五版 中文版 练习 10.20 个人code
- C++ primer 第五版 中文版 练习 10.24个人code
- C++ primer 第五版 中文版 练习 10.29 个人code
- C++ primer 第五版 中文版 练习 11.23 个人code
- C++ primer(第五版) 练习 4.31 个人code 和 疑惑
- C++ primer(第五版) 练习 5.23、5.24、5.25 个人code
- C++ primer(第五版) 练习 7.11 个人 code
- C++ primer 第五版 中文版 练习 9.45 个人code 及疑问
- C++ primer 第五版 中文版 练习 10.13 个人code
- C++ primer 第五版 中文版 练习 10.31 个人code
- C++ primer 第五版 中文版 练习 11.31 个人code
- C++ Primer 第五版 中文版 练习 13.39 个人code
- C++ primer(第五版) 练习 3.17 个人code
- C++ primer(第五版) 练习 3.31 个人code
- C++ primer(第五版) 练习 3.43 个人code
- C++ primer 第五版 中文版 练习 10.14 个人code
- C++ primer 第五版 中文版 练习 10.30 个人code
- C++ primer 第五版 中文版 练习 11.12 个人code
- C++ primer 第五版 中文版 练习 12.19 个人code