当前位置:网站首页>50.【Application of dynamic two-dimensional array】
50.【Application of dynamic two-dimensional array】
2022-08-01 09:28:00 【Lee is struggling...】
==================
[The number of columns can only be entered manually, the number of rows can be dynamic]
#include
using namespace std;
int main()
{
int m, n;
cout << "Please enter the number of lines:" << endl;
cin >> m;
cout << "Please enter the number of columns:" << endl;
cin >> n;
int(*p)[n]; // The number of columns cannot be entered dynamically
p = new int[m][n];
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 3; j++)
{
cout << "Please enter the value of p[" << i << "][" << j << "]" << endl;
cin >> p[i][j];
}
}
cout << "The output is:" << endl;
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 3; j++)
{
cout<< p[i][j]<<" ";
}
}
return 0;
}
[Manual input of the number of columns can be run]
#include
using namespace std;
int main()
{
int m, n;
cout << "Please enter the number of lines:" << endl;
cin >> m;
int(*p)[3];
p = new int[m][3];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < 3; j++)
{
cout << "Please enter the value of p[" << i << "][" << j << "]" << endl;
cin >> p[i][j];
}
}
cout << "The output is:" << endl;
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 3; j++)
{
cout<< p[i][j]<<" ";
}
}
return 0;
}
【Basic format】
int (*p)[column]
p=new int[row][column]
边栏推荐
- Install GBase 8 c database, the error shows "Resource, how to solve?
- How to get page data
- Quantify daily work metrics
- 将Servlet项目改为SSM项目
- Detailed explanation of JVM runtime data area and JMM memory model
- HoloView 在 jyputer lab/notebook 不显示总结
- Leicester Weekly 304 6135. The longest ring in the picture Inward base ring tree
- Mysql database deployment and initialization steps
- leetcode-6133: maximum number of groupings
- C语言小游戏——扫雷
猜你喜欢
《时代》杂志:元宇宙时代将改变世界
leetcode-6134: Find the closest node to the given two nodes
自定义IP在PCIE中使用
Analysis of High Availability Solution Based on MySql, Redis, Mq, ES
ASP.NET Core 6框架揭秘实例演示[30]:利用路由开发REST API
【Untitled】
报告:想学AI的学生数量已涨200%,老师都不够用了
Get the Token from the revised version of Qubutu Bed
50.【动态二维数组的运用】
C语言小游戏——扫雷
随机推荐
用OpenCV的边缘检测
CTO强烈禁止使用Calendar,那用啥?
Shell executes SQL to send emails
MySQL query advanced - from the use of functions to table joins, do you remember?
The use of scrapy crawler framework
Microsoft Azure & NVIDIA IoT developers season I | Azure IoT & NVIDIA Jetson development foundation
ASP.NET Core 6框架揭秘实例演示[30]:利用路由开发REST API
HoloView--Customization
Redis中间件(从搭建到弃坑)
MySQL查询进阶——从函数到表连接的使用你还记得吗
高级驾驶辅助系统ADAS简介
Shell: Conditional test action
ACmix 论文精读,并解析其模型结构
leetcode-6132: Make all elements in array equal to zero
net stop/start mysql80 拒绝访问
扁平数组转树结构实现方式
常见的API安全缺陷有哪些?
HoloView -- Tabular Datasets
JVM内存模型之深究模型特征
How does UXDB return the number of records for all tables in the current database?