第十二周上机项目1 阅读程序(2)

来源:互联网 发布:2016年网络热议话题 编辑:程序博客网 时间:2024/05/22 04:26
问题及代码:/ *                                        *Copyright  (c)  2014,烟台大学计算机学院   *All rights reserved .                        *文件名称:test .cpp                       *作    者:曹莉萍                        *完成日期:2014 年11月13日             *版 本 号:v1.0                           *                                        *问题描述:                              *输入描述:                              *程序输出:                              * /                     #include <iostream>using namespace std;int a=3,b=5;int max(int a,int b){    int c;    c=a>b?a:b;    return c;}int main( ){    int a=8;    cout<<max(a,b)<<endl;    return 0;}

运行结果



问题及代码:/ *                                        *Copyright  (c)  2014,烟台大学计算机学院   *All rights reserved .                        *文件名称:test .cpp                       *作    者:曹莉萍                        *完成日期:2014 年11月13日             *版 本 号:v1.0                           *                                        *问题描述:全局变量的程序                              *输入描述:                              *程序输出:                              * /          #include <iostream>using namespace std;void cude( );int main ( ){    extern int x;    x=5;    cude ( );    cout<<x<<endl;    return 0;}int x=10;void cude( ){    x=x*x*x;}

运行结果


0 0