当前位置:网站首页>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列
边栏推荐
- Project management essence reading notes (VII)
- (二)进制
- Using activity to realize a simple inputable dialog box
- Qt:qss custom qspinbox instance
- "Core values of testing" and "super complete learning guide for 0 basic software testing" summarized by test engineers for 8 years
- Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche
- Logstash backup tracks the data records reported
- After 8 years of industry thinking, the test director has a deeper understanding of test thinking
- I have been doing software testing for three years, and my salary is less than 20K. Today, I put forward my resignation
- The five-year itch of software testing engineers tells the experience of breaking through bottlenecks for two years
猜你喜欢

历经一个月,终于拿到金蝶Offer!分享一下四面面经+复习资料

做软件测试三年,薪资不到20K,今天,我提出了辞职…

QT: QSS custom qtableview instance

数据库增量备份 - DB INCR DB FULL

我对测试工作的一些认识(资深测试人员总结)

Communication software development and Application

AIDL

php服务器 与redis交互大量CLOSE_WAIT分析

The testing department of the company came to the king of the Post-00 roll, and the veteran exclaimed that it was really dry, but

What is the salary level of 17k? Let's take a look at the whole interview process of post-95 Test Engineers
随机推荐
Comment réaliser des tests automatisés pour les tests logiciels embarqués?
ExecutorException: Statement returned more than one row, where no more than one was expected.
Qt:qss custom qlineedit instance
php服务器 与redis交互大量CLOSE_WAIT分析
读书笔记:《心若菩提》 曹德旺
Hard goods | write all the codes as soon as you change the test steps? Why not try yaml to realize data-driven?
Exclusive analysis | truth about resume and interview
在职美团测试工程师的这八年,我是如何成长的,愿技术人看完都有收获
Hal -- writing hardware drivers
[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder
如何让让别人畏惧你
After 8 years of industry thinking, the test director has a deeper understanding of test thinking
Summary of the history of Mathematics
Project management essence reading notes (VII)
Ext file system mechanism principle
帝国cms 无缩略图 灵动标签(e:loop)判断有无标题图片(titlepic)的两种写法
"Core values of testing" and "super complete learning guide for 0 basic software testing" summarized by test engineers for 8 years
10. Nacos source code construction
软件测试工程师的5年之痒,讲述两年突破瓶颈经验
2021 postgraduate entrance examination mathematics 2 linear algebra