投稿  收藏 

题目信息

题目类型
练习
题目年份
2023
题目题型
编程题
关 键 词
函数

题目题干

指出下列程序各函数中的全局变量与局部变量、静态变量与动态变量,以及各变量的存储类型、作用域与生存期,并写出下列程序的运行结果。
  1. #include <iostream> //0 
  2. using namespace std; /1 
  3. extern int x; //2 
  4. void change(void//3 
  5. register int y=0,z=3; //4 
  6. cout<<x<<'\t'<<y<<’\t'<<z<<endl; //5 
  7. x=2;y=2; //6 
  8. cout<<x<<'\t'<<y<<’\t'<<z<<endl; //7 
  9. //8 
  10. int x=3,y=4; //9 
  11. int main( ) //10 
  12. { auto int x,z= -3; //11 
  13. x=1; //12 
  14. cout<<x<<'\t'<<y<<’\t'<<z<<endl; //13 
  15. change(); //14 
  16. cout<<x<<'\t'<<y<<’\t'<<z<<endl; //15 
  17. cout<<::x<<'\t'<<::y<<’\t'<<z<<endl; //16 
  18. return 0; //17 
  19. //18 
指出下列程序各函数中的全局变量与局部变量、静态变量与动态变量,以及各变量的存储类型、作用域与生存期,并写出下列程序的运行结果。 #include <iostream> //0  using namespace std; /1  extern int x; //2  void change(void) //3  { register int y=0,z=3; //4  cout<<x<<'\t'<<y<<’\t'<<z<<endl; //5  x=2;y=2; //6  cout<<x<<'\t'<<y<<’\t'<<z<<endl; //7  } //8  int x=3,y=4; //9  int main( ) //10  { auto int x,z= -3; //11  x=1; //12  cout<<x<<'\t'<<y<<’\t'<<z<<endl; //13  change(); //14  cout<<x<<'\t'<<y<<’\t'<<z<<endl; //15  cout<<::x<<'\t'<<::y<<’\t'<<z<<endl; //16  return 0; //17  } //18 

答案解析

相关题目

指出下列各函数中各变量的存储类型、作用域与生存期,写出下列程序的运行结果。 #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 题中学生成绩表用擂台法按总成绩升序排序后输出,并输出每门课程不及格学生的学号、课程名称及成绩。
某小组有 5 个学生,考了 3 门课程,他们的学号及成绩如表 4.3 所示,试编程求每个学生的总成绩及每门课的最高分,并按表格形式输出每个学生的学号、3 门课程成绩、总成绩及各门课程的最高分。要求用一

提示声明

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

猜你喜欢