当前位置:网站首页>C language two-dimensional array
C language two-dimensional array
2022-07-03 11:18:00 【Xiaohao programming】
C Speech two-dimensional array
The following code is to traverse the values in the two-dimensional array and output
#include <stdio.h>
int main()
{
int array[2][3] = {
{
1,2,3},{
4,5,6}};
int i,j;
for(i=0;i<2;i++)// That's ok , Cycle twice
{
for(j=0;j<3;j++)// Column , loop 3 Time
{
printf("%d %p ",array[i][j],&array[i][j]);// Type the address together
}
putchar('\n');// Line break
}
return 0;
}
Output results
1 0061FF00 2 0061FF04 3 0061FF08
4 0061FF0C 5 0061FF10 6 0061FF14
Example :
Find the largest number in the following data , And output in the rows and columns
arry[3][4] = {
134,342,33,43,555,356,27,58,92,36,933,367};
Code up
#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++)// In order to transform more vividly , Output it
{
for(j=0;j<4;j++)
{
printf("%d\t",arry[i][j]);// /t Horizontal tab with table , To look good
}
printf("\n");// Line break
}
max = arry[0][0];// Give the first one to MAX As a reference
for(i=0;i<3;i++)// Compare one by one , That's ok
{
for(j=0;j<4;j++)// Compare one by one , Column
{
if(max < arry[i][j])
{
max = arry[i][j];
hang = i;// The line where the record is located
lie = j;// The column where the record is located
}
}
}
printf(" The maximum number is %d In the %d Walk in %d Column ",max,hang+1,lie+1);// Add 1 In order to , People live from 1 Start , And the computer is from 0 Start
return 0;
}
Output result
134 342 33 43
555 356 27 58
92 36 933 367
The maximum number is 933 In the 3 Walk in 3 Column
边栏推荐
- Empire CMS no thumbnail smart tag (e:loop) two ways to judge whether there is a titlepic
- Tencent micro app to get wechat user information
- [VTK] vtkWindowedSincPolyDataFilter 源码注释解读
- 如何成为一名高级数字 IC 设计工程师(1-2)Verilog 编码语法篇:Verilog 1995、2001、2005 标准
- 15 software testing Trends Worthy of attention
- 在腾讯云容器服务Node上执行 kubectl
- What are the strengths of "testers"?
- After a month, I finally got Kingdee offer! Share tetrahedral Sutra + review materials
- 如何成为一名高级数字 IC 设计工程师(1-4)Verilog 编码语法篇:表达式
- AIDL
猜你喜欢
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
[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
Game test related tests a hero's skills (spring moves are asked more questions)
Comment réaliser des tests automatisés pour les tests logiciels embarqués?
在职美团测试工程师的这八年,我是如何成长的,愿技术人看完都有收获
After a month, I finally got Kingdee offer! Share tetrahedral Sutra + review materials
Résumé des questions d'entrevue (2) Modèle io, ensemble, principe NiO, pénétration du cache, avalanche de rupture
反正切熵(Arctangent entropy):2022.7月最新SCI论文
Activity and fragment lifecycle
Solve undefined reference to`__ aeabi_ Uidivmod 'and undefined reference to`__ aeabi_ Uidiv 'error
随机推荐
在职美团测试工程师的这八年,我是如何成长的,愿技术人看完都有收获
Latest sales volume of pinduoduo
Comment réaliser des tests automatisés pour les tests logiciels embarqués?
Illustrated network: what is virtual router redundancy protocol VRRP?
线性表的双链表
搭建ADG后,实例2无法启动 ORA-29760: instance_number parameter not specified
How can UI automated testing get out of trouble? How to embody the value?
Analysis of JMM memory model
Android log system
【obs】obs的ini格式的ConfigFile
Lecture 1 number field
10. Nacos source code construction
ByteDance layoffs, test engineers were almost destroyed: how terrible is the routine behind the recruitment of large factories?
T5 attempt
2022 pinduogai 100000 sales tutorial
Touch and screen automatic rotation debugging
Solve undefined reference to`__ aeabi_ Uidivmod 'and undefined reference to`__ aeabi_ Uidiv 'error
Ext file system mechanism principle
After 8 years of industry thinking, the test director has a deeper understanding of test thinking
2. Hal hardware abstraction layer