投稿  收藏 

题目信息

题目类型
练习
题目年份
2024
题目题型
单选题
关 键 词
函数

题目题干

指出下列各函数中各变量的存储类型、作用域与生存期,写出下列程序的运行结果。
#include <iostream> //0
using namespace std; //1
int main( ) //2
{ int i; //3
void add1(void),add2(void); //4
for (i=0;i<3;i++) //5
{ add1(); //6
add2(); //7
cout<<endl; //8
}
return 0; //9
} //10
void add1(void) //11
{ int x=0; //12
x++; //13
cout<<x<<'\t'; //14
} //15
void add2(void) //16
{ static int x=0; //17
x++; //18
cout<<x<<'\t'; //19
} //20
变量分析:
指出下列各函数中各变量的存储类型、作用域与生存期,写出下列程序的运行结果。 #include <iostream> //0 using namespace std; //1 int main( ) //2 { int i; //3 void add1(void),add2(void); //4 for (i=0;i<3;i++) //5 { add1(); //6 add2(); //7 cout<<endl; //8 } return 0; //9 } //10 void add1(void) //11 { int x=0; //12 x++; //13 cout<<x<<'\t'; //14 } //15 void add2(void) //16 { static int x=0; //17 x++; //18 cout<<x<<'\t'; //19 } //20

答案解析

相关题目

指出下列各文件中变量的存储类型、作用域与生存期,写出下列程序的运行结果。在第二个文件中能否将第一个文件中的变量 z 定义为外部变量? //文件名:exercise5_18.cpp #include &
指出下列各函数中各变量的存储类型、作用域与生存期,写出下列程序的运行结果。 #include <iostream> //0 using namespace std; //1 int mai
指出下列程序各函数中的全局变量与局部变量、静态变量与动态变量,以及各变量的存储类型、作用域与生存期,并写出下列程序的运行结果。 #include <iostream> //0  using
写出下列程序的运行结果。 #include <iostream> using namespace std; int a=10; int main( ) {int a=20,b=30; {i
写出下列以数组为参数的函数调用运行结果。 #include <iostream>  #include <string>  using namespace std;  int m
写出下列递归程序的递归公式、限制条件、结束条件及运行结果。
写出下列程序运行后的输出图形。
写出下列程序的运行结果。 #include <iostream>  using namespace std;  void modify(int x,int y)  { cout<&l
设 A 为 m 行 n 列矩阵,B 为 n 行 k 列矩阵,C 为 m 行 k 列矩阵。设计矩阵乘法程序,能完成 C=A * B 的操作。m、n 与 k 用 define 定义为常量,其值由用户自定义
对 4.19 题中学生成绩表用擂台法按总成绩升序排序后输出,并输出每门课程不及格学生的学号、课程名称及成绩。

提示声明

  • 免责声明:本站资源均来自网络或者用户投稿,仅供用于学习和交流:如有侵权联系删除!
  • 温馨提示:本文属于积分文章,需要充值获得积分或升级VIP会员,也可在会员中心投稿获取。

猜你喜欢