当前位置:网站首页>C语言二维数组
C语言二维数组
2022-07-03 10:02:00 【小浩编程】
C语音二维数组
下面代码是将二维数组中的值进行遍历输出
#include <stdio.h>
int main()
{
int array[2][3] = {
{
1,2,3},{
4,5,6}};
int i,j;
for(i=0;i<2;i++)//行,循环两次
{
for(j=0;j<3;j++)//列,循环3次
{
printf("%d %p ",array[i][j],&array[i][j]);//将地址也一同打出
}
putchar('\n');//换行
}
return 0;
}
输出结果
1 0061FF00 2 0061FF04 3 0061FF08
4 0061FF0C 5 0061FF10 6 0061FF14
例题:
在下列数据中找到最大的数,并输出在第几行第几列
arry[3][4] = {
134,342,33,43,555,356,27,58,92,36,933,367};
上代码
#include <stdio.h>
int main()
{
int arry[3][4] = {
134,342,33,43,555,356,27,58,92,36,933,367};
int i,j;
int hang,lie;
int max;
for(i=0;i<3;i++)//为了更形象的转化一下,进行输出出来
{
for(j=0;j<4;j++)
{
printf("%d\t",arry[i][j]);// /t带表水平制表符,为了好看
}
printf("\n");//换行
}
max = arry[0][0];//将第一个先给到MAX进行作为参照
for(i=0;i<3;i++)//挨个顺序进行比较,行
{
for(j=0;j<4;j++)//挨个顺序进行比较,列
{
if(max < arry[i][j])
{
max = arry[i][j];
hang = i;//记录所在的行
lie = j;//记录所在的列
}
}
}
printf("最大的数是%d在第%d行在%d列",max,hang+1,lie+1);//加1是为了,人们生活中是从1开始,而计算机是从0开始
return 0;
}
输出的结果
134 342 33 43
555 356 27 58
92 36 933 367
最大的数是933在第3行在3列
边栏推荐
- Oracle收回权限 & 创建角色
- 在腾讯云容器服务Node上执行 kubectl
- Crawl with requests
- Qt:qss custom qpprogressbar instance
- [true question of the Blue Bridge Cup trials 44] scratch eliminate the skeleton Legion children programming explanation of the true question of the Blue Bridge Cup trials
- QT: QSS custom qtabwidget and qtabbar instances
- Logstash backup tracks the data records reported
- Qt:qss custom QSlider instance
- 封装一个koa分布式锁中间件来解决幂等或重复请求的问题
- 面试题总结(2) IO模型,集合,NIO 原理,缓存穿透,击穿雪崩
猜你喜欢

I, a tester from a large factory, went to a state-owned enterprise with a 50% pay cut. I regret it

字节跳动大裁员,测试工程师差点遭团灭:大厂招人背后的套路,有多可怕?

. Net core - a queuing system for wechat official account

QT: QSS custom qtreeview instance

How did I grow up in the past eight years as a test engineer of meituan? I hope technicians can gain something after reading it
![[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder](/img/1f/729594930c7c97d3e731987f4c3645.png)
[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder

Multiple IO transfer - preamble

面试题总结(2) IO模型,集合,NIO 原理,缓存穿透,击穿雪崩

(二)进制

How to realize automatic testing in embedded software testing?
随机推荐
Project management essence reading notes (6)
redis那些事儿
Do you really need automated testing?
2. Hal hardware abstraction layer
Google Earth Engine(GEE)——当我们前后影像来弥补插值效果得时候,没有效果怎么办?
ORACLE 11G 单机冷备数据库
触摸与屏幕自动旋转调试
How to realize automatic testing in embedded software testing?
one hot 独热码
Game test related tests a hero's skills (spring moves are asked more questions)
Qt:qss custom qmenu instance
大厂技术专家:工程师如何提升沟通能力?
帝国cms 无缩略图 灵动标签(e:loop)判断有无标题图片(titlepic)的两种写法
Qt:qss custom qspinbox instance
软件测试(测试用例)编写之俗手、本手、妙手
Qt:qss custom qgroupbox instance
行业唯一!法大大电子合同上榜36氪硬核科技企业
Error installing the specified version of pilot
The normal one inch is 25.4 cm, and the image field is 16 cm
Stack, monotone stack, queue, monotone queue