当前位置:网站首页>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列
边栏推荐
- T5 attempt
- Hal -- writing hardware drivers
- 封装一个koa分布式锁中间件来解决幂等或重复请求的问题
- Logstash backup tracks the data records reported
- 英特尔13代酷睿旗舰曝光,单核5.5GHz
- Definition and properties of summation symbols
- Error installing the specified version of pilot
- ExecutorException: Statement returned more than one row, where no more than one was expected.
- EPS电动转向系统分析
- "Core values of testing" and "super complete learning guide for 0 basic software testing" summarized by test engineers for 8 years
猜你喜欢
11. Provider service registration of Nacos service registration source code analysis
【obs】obs的ini格式的ConfigFile
EPS电动转向系统分析
Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche
嵌入式軟件測試怎麼實現自動化測試?
"Core values of testing" and "super complete learning guide for 0 basic software testing" summarized by test engineers for 8 years
What is the salary level of 17k? Let's take a look at the whole interview process of post-95 Test Engineers
The normal one inch is 25.4 cm, and the image field is 16 cm
[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder
Résumé des questions d'entrevue (2) Modèle io, ensemble, principe NiO, pénétration du cache, avalanche de rupture
随机推荐
Qt:qss custom qgroupbox instance
2022 pinduogai 100000 sales tutorial
Balance between picture performance of unity mobile game performance optimization spectrum and GPU pressure
如何:配置 ClickOnce 信任提示行为
你真的需要自动化测试吗?
. Net core - a queuing system for wechat official account
Solution: jupyter notebook does not pop up the default browser
The five-year itch of software testing engineers tells the experience of breaking through bottlenecks for two years
Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡
帝国cms 无缩略图 灵动标签(e:loop)判断有无标题图片(titlepic)的两种写法
Matlab memory variable management command
The role and necessity of implementing serializable interface
8年测试总监的行业思考,看完后测试思维认知更深刻
浅析-JMM内存模型
Software testing e-commerce projects that can be written into your resume, don't you come in and get it?
Test what the leader should do
Qt:qss custom qmenubar instance
ORACLE 11G 单机冷备数据库
做软件测试三年,薪资不到20K,今天,我提出了辞职…
Project management essence reading notes (6)