当前位置:网站首页>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;
}边栏推荐
- 【LeetCode】老虎证券面试-括号嵌套且满足优先级
- gpnmb+ gpnmb-AT2 cell空转映射 上皮细胞的空转映射
- 浅聊缓存函数
- When deleting a folder, the error "Error ox80070091: The directory is not empty" is reported. How to solve it?
- Chrome F12 keep before request information network
- Batch PNG format can be converted to JPG format
- STP和RSTP的BPDU报文中flag位 对比+分析
- SQL Daily Practice (Nioke New Question Bank) - Day 5: Advanced Query
- 命令行加载特效 【cli-spinner.js】 实用教程
- Exception: Dataset not found. Solution
猜你喜欢
随机推荐
【微信小程序】底部有安全距离,适配iphone X等机型的解决方案
兔起鹘落全端涵盖,Go lang1.18入门精炼教程,由白丁入鸿儒,全平台(Sublime 4)Go lang开发环境搭建EP00
Redis和MySQL如何保持数据一致性
110道 MySQL面试题及答案 (持续更新)
Path Prefixes (倍增!树上の二分)
【LeetCode】112.路径总和
Cartesi 2022 年 7 月回顾
手把手教你如何自制目标检测框架(从理论到实现)
多媒体数据处理实验3:图像特征提取与检索
Let‘s Encrypt 使用
机器学习(公式推导与代码实现)--sklearn机器学习库
【字节面试】word2vector输出多少个类别
Exception: Dataset not found.解决办法
ClickHouse 数据插入、更新与删除操作 SQL
批量将PNG格式转化为JPG格式
go版本升级
Add Modulo 10 (规律循环节,代码实现细节)
阿里云·短信发送
MySQL的存储过程
深度学习之 10 卷积神经网络2









