当前位置:网站首页>局部变量的数组初始化问题
局部变量的数组初始化问题
2022-07-06 23:08:00 【疯疯癫癫才自由】
当数组不是全局变量时:
如果数组大小是变量,则数组初始化为0时,元素的值也许不是0;
如果数组大小是常量,则数组初始化为0时,元素的值是0;
/**
当数组不是全局变量时:
如果数组大小是变量,则数组初始化为0时,元素的值也许不是0;
如果数组大小是常量,则数组初始化为0时,元素的值是0;
*/
#include <iostream>
using namespace std;
const int maxn=10;
int main()
{
cout << "数组大小是变量:\n";
cout << "输入两个值:\n";
int n, m;
cin >> n >> m;
int temp[n][m]={0};
for(int i=0;i<n;++i)
for(int j=0;j<m;++j)
cout << temp[i][j] << ' ';
cout << "\n数组大小是const 类型的常量:\n";
int matr[maxn][maxn]={0};
for(int i=0;i<maxn;++i)
for(int j=0;j<maxn;++j)
cout << matr[i][j] << ' ';
cout << "\n数组大小就是 common 常量:\n";
int a[10][10]={0};
for(int i=0;i<10;++i)
for(int j=0;j<10;++j)
cout << a[i][j] << ' ';
}
边栏推荐
- 使用知云阅读器翻译统计遗传学书籍
- U++ game learning notes
- Operand of null-aware operation ‘!‘ has type ‘SchedulerBinding‘ which excludes null.
- What is Web3
- 【Android Kotlin协程】利用CoroutineContext实现网络请求失败后重试逻辑
- Why JSON is used for calls between interfaces, how fastjson is assigned, fastjson 1.2 [email protected] Mapping relatio
- PLC Analog output analog output FB analog2nda (Mitsubishi FX3U)
- Markdown编辑器
- 精彩速递|腾讯云数据库6月刊
- The most complete learning rate adjustment strategy in history LR_ scheduler
猜你喜欢

When knative meets webassembly

5G VoNR+之IMS Data Channel概念

Meow, come, come: do you really know if, if else

offer如何选择该考虑哪些因素

Techniques d'utilisation de sublime

U++ metadata specifier learning notes

Batch normalization (Standardization) processing

If you‘re running pod install manually, make sure flutter pub get is executed first.

Operand of null-aware operation ‘!‘ has type ‘SchedulerBinding‘ which excludes null.

c语言神经网络基本代码大全及其含义
随机推荐
Addressable 预下载
Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
装饰器基础学习02
Basic knowledge of road loss of 3GPP channel model
[ArcGIS tutorial] thematic map production - population density distribution map - population density analysis
高数中值定理总结
No experts! Growth secrets for junior and intermediate programmers and "quasi programmers" who are still practicing in Universities
Using thread class and runnable interface to realize the difference between multithreading
Meow, come, come: do you really know if, if else
Two methods of chromosome coordinate sequencing
U++ 游戏类 学习笔记
STM32 encapsulates the one key configuration function of esp8266: realize the switching between AP mode and sta mode, and the creation of server and client
Canteen user dish relationship system (C language course design)
STM32F103 realize IAP online upgrade application
Redis如何实现多可用区?
最全常用高数公式
PLC Analog output analog output FB analog2nda (Mitsubishi FX3U)
y58.第三章 Kubernetes从入门到精通 -- 持续集成与部署(三一)
STM32F103ZE+SHT30检测环境温度与湿度(IIC模拟时序)
CentOS 7.9安装Oracle 21c历险记