当前位置:网站首页>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
边栏推荐
- AMS Series 1 - AMS startup process
- 大厂技术专家:工程师如何提升沟通能力?
- 做软件测试三年,薪资不到20K,今天,我提出了辞职…
- Is pinduogai's sales safe in 2022?
- I, a tester from a large factory, went to a state-owned enterprise with a 50% pay cut. I regret it
- 00后抛弃互联网: 毕业不想进大厂,要去搞最潮Web3
- Matlab memory variable management command
- Hal - General
- Internet Socket (非)阻塞write/read n个字节
- 面试题总结(2) IO模型,集合,NIO 原理,缓存穿透,击穿雪崩
猜你喜欢

Activity and fragment lifecycle

基于I2C协议的驱动开发

Résumé des questions d'entrevue (2) Modèle io, ensemble, principe NiO, pénétration du cache, avalanche de rupture

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

Solution: jupyter notebook does not pop up the default browser

Unique in the industry! Fada electronic contract is on the list of 36 krypton hard core technology enterprises

英特尔13代酷睿旗舰曝光,单核5.5GHz

What is the salary level of 17k? Let's take a look at the whole interview process of post-95 Test Engineers

Communication software development and Application

Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche
随机推荐
How to realize automatic testing in embedded software testing?
基于I2C协议的驱动开发
The highest monthly salary of 18K has a good "mentality and choice", and success is poor "seriousness and persistence"~
00后抛弃互联网: 毕业不想进大厂,要去搞最潮Web3
Touch and screen automatic rotation debugging
12. Nacos server service registration of source code analysis of Nacos service registration
Is pinduogai's sales safe in 2022?
图解网络:什么是虚拟路由器冗余协议 VRRP?
2022-07-02:以下go语言代码输出什么?A:编译错误;B:Panic;C:NaN。 package main import “fmt“ func mai
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
MATLAB提取不规则txt文件中的数值数据(简单且实用)
ConstraintLayout跟RelativeLayout嵌套出现的莫名奇妙的问题
Commonly used discrete random distribution
In the middle of the year, I have prepared a small number of automated interview questions. Welcome to the self-test
EPS电动转向系统分析
Ext file system mechanism principle
redis那些事儿
解决undefined reference to `__aeabi_uidivmod‘和undefined reference to `__aeabi_uidiv‘错误
What kind of living condition is a tester with a monthly salary of more than 10000?
Tencent micro app to get wechat user information