当前位置:网站首页>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第三题(Longest Substring Without Repeating Characters)三部曲之二:编码实现
mysql 事务原理详解
GO开发环境配置
MySQL-TCL语言-transaction control language事务控制语言
10 minutes to get you started chrome (Google) browser plug-in development
013-Binary tree
pytorch one-hot 小技巧
Chrome F12 keep before request information network
English Grammar - Adverbial Clauses
英文语法-状语从句
随机推荐
xtrabackup
多媒体数据处理实验2:PCA
go中select语句
Industry SaaS Microservice Stability Guarantee Actual Combat
【LeetCode】老虎证券面试-括号嵌套且满足优先级
Redis集群概念与搭建
WinCheck Script
响应式布局经典范例——巨幅背景大标题
flutter 应用 抓包
【LeetCode】112. Path sum
For heavy two-dimensional arrays in PHP
浅析什么是伪类和伪元素?伪类和伪元素的区别解析
mysqldump导出提示:mysqldump [Warning] Using a password on the command line interface can be insecure
Exception: Dataset not found. Solution
深度学习之 10 卷积神经网络1
scala减少,reduceLeft reduceRight,折叠,foldLeft foldRight
好用的插件
STP生成树(端口状态+端口角色+收敛机制 )|||| STP优化技术( uplinkfast技术+Portfast技术+backbonefast技术 )详解
MySQL 中 is null 和 =null 的区别
【网络安全】Kail操作系统