首页 > 其他 > 详细

自考新教材--p109

时间:2019-12-23 09:30:50      阅读:87      评论:0      收藏:0      [点我收藏+]

源程序:

#include <iostream>

using namespace std;

static int glos = 100;

void f()

{

  int a = 1;

  static int fs = 1;

  cout << "在f中:a(自动)=" << a << " fs(静态)=" << fs << " glos(静态)=" << glos << endl;

  a += 2;

  fs += 2;

  glos += 10;

  cout << "在f中:a(自动)=" << a << " fs(静态)=" << fs << " glos(静态)=" << glos << endl;

}

 

int main()

{

  static int ms = 10;

  for (int i = 1; i <= 3; i++)

    f();

  cout << "ms=" << ms << endl;

  cout << "glos=" << glos << endl;

  system("pause");

  return 0;

}

运行结果:

技术分享图片 

自考新教材--p109

原文:https://www.cnblogs.com/duanqibo/p/12081984.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!