第十二周项目一(1)阅读程序

来源:互联网 发布:岛崎遥香握手数据切 编辑:程序博客网 时间:2024/04/25 13:16
1./*  2. * Copyright (c) 2014, 烟台大学计算机学院  3. * All rights reserved.  4. * 文件名称:test.cpp  5. * 作    者:张震刚   6. * 完成日期:2014年 11 月 13 日  7. * 版 本 号:v1.0  8. *  9. * 问题描述:体验静态局部变量。10.* 输入描述: 无11.* 程序输出:无12.*/
#include <iostream>using namespace std;int f(int n);int main(){    cout<<f(5)<<" ";    cout<<f(8)<<endl;    return 0;}int f(int n){    static int a=2;    int b=0;    a+=n;    b+=a;    return b;}
<pre class="cpp" name="code">#include <iostream>using namespace std;int func(int a,int b){    static int m=0,i=2;    i+=m+1;    m=i+a+b;    return m;}int main(){    int k=4,m=1,p;    p=func(k,m);    cout<<p<<endl;    p=func(k,m);    cout<<p<<endl;    return 0;}




0 0