当前位置:网站首页>Array initialization of local variables
Array initialization of local variables
2022-07-07 05:09:00 【Madness makes freedom】
When the array is not a global variable :
If the array size is a variable , Then the array is initialized to 0 when , The value of the element may not be 0;
If the array size is constant , Then the array is initialized to 0 when , The value of the element is 0;
/**
When the array is not a global variable :
If the array size is a variable , Then the array is initialized to 0 when , The value of the element may not be 0;
If the array size is constant , Then the array is initialized to 0 when , The value of the element is 0;
*/
#include <iostream>
using namespace std;
const int maxn=10;
int main()
{
cout << " Array size is a variable :\n";
cout << " Enter two values :\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 The array size is const Constant of type :\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 The array size is common Constant :\n";
int a[10][10]={0};
for(int i=0;i<10;++i)
for(int j=0;j<10;++j)
cout << a[i][j] << ' ';
}
边栏推荐
- 【736. Lisp 语法解析】
- Decorator basic learning 02
- Liste des hôtes d'inventaire dans ansible (je vous souhaite des fleurs et de la romance sans fin)
- [Yugong series] go teaching course 005 variables in July 2022
- U++ game learning notes
- File upload vulnerability summary
- Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
- DFS,BFS以及图的遍历搜索
- Stm32f103ze+sht30 detection of ambient temperature and humidity (IIC simulation sequence)
- 如何设计 API 接口,实现统一格式返回?
猜你喜欢
Understand common network i/o models
U++4 接口 学习笔记
U++ metadata specifier learning notes
全链路压测:影子库与影子表之争
sublime使用技巧
Flask project uses flask socketio exception: typeerror: function() argument 1 must be code, not str
Ansible报错:“msg“: “Invalid/incorrect password: Permission denied, please try again.“
《四》表单
[Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails
IMS data channel concept of 5g vonr+
随机推荐
LabVIEW在打开一个新的引用,提示内存已满
A row of code r shows the table of Cox regression model
Servicemesh mainly solves three pain points
ServiceMesh主要解决的三大痛点
How to design API interface and realize unified format return?
JS variable case
Sublime tips
The sooner you understand the four rules of life, the more blessed you will be
[ArcGIS tutorial] thematic map production - population density distribution map - population density analysis
史上最全学习率调整策略lr_scheduler
STM32F103ZE+SHT30检测环境温度与湿度(IIC模拟时序)
Decorator basic learning 02
Leetcode(46)——全排列
CentOS 7.9安装Oracle 21c历险记
U++ game learning notes
torch optimizer小解析
带你遨游银河系的 10 种分布式数据库
sublime使用技巧
JS variable plus
Monitoring cannot be started after Oracle modifies the computer name