当前位置:网站首页>C语言二维数组用一维数组进行调用
C语言二维数组用一维数组进行调用
2022-08-03 09:30:00 【smith342】
以前就知道C语言的二维数组在内存中是一维数组进行存储的,但是没有试过使用一维数组对二维数组进行调用。
如下代码输出为:
17 24 17
8 42 22
17 24 17 8 42 22
原以为编译会报错,但实际上没有报错。
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int arr[2][3];
srand(time(0));
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
arr[i][j]=rand()%50+1;
for(int i=0;i<2;i++)
{
for(int j=0;j<3;j++)
//cout<<arr[i][j]<<'\t';
printf("%d\t",arr[i][j]);
//cout<<endl;
printf("\n");
}
for(int i=0;i<6;i++)
//cout<<arr[0][i]<<'\t';
printf("%d\t",arr[0][i]);
return 0;
}
边栏推荐
- mysql8安装步骤教程
- 110 MySQL interview questions and answers (continuous updates)
- 多媒体数据处理实验3:图像特征提取与检索
- go泛型使用方法
- 线程介绍与使用
- 【字节面试】word2vector输出多少个类别
- Flink Yarn Per Job - 创建启动Dispatcher RM JobManager
- LINGO 18.0 software installation package download and installation tutorial
- AUC的两种计算方式
- Chrome F12 keep before request information network
猜你喜欢
随机推荐
MySQL-TCL语言-transaction control language事务控制语言
慢 SQL 分析与优化
自动化测试浏览器驱动下载版本对应关系
Flink Yarn Per Job - 启动AM
flush tables
Machine learning (formula derivation and code implementation)--sklearn machine learning library
MySQL-存储过程-函数-
MySQL的主从复制
删除文件夹时,报错“错误ox80070091:目录不是空的”,该如何解决?
dflow入门4——recurse&reuse&conditional
cnpm安装步骤
命令行加载特效 【cli-spinner.js】 实用教程
手把手教你如何自制目标检测框架(从理论到实现)
selenium IDE的3种下载安装方式
STP和RSTP的BPDU报文中flag位 对比+分析
【字节面试】word2vector输出多少个类别
Go操作Redis数据库
MySQL_关于JSON数据的查询
Exception: Dataset not found.解决办法
梯度消失和梯度爆炸