当前位置:网站首页>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
边栏推荐
- 可以写进简历的软件测试电商项目,不进来get一下?
- MATLAB提取不规则txt文件中的数值数据(简单且实用)
- 如何成为一名高级数字 IC 设计工程师(1-4)Verilog 编码语法篇:表达式
- Reading notes: heart like Bodhi, Cao Dewang
- One hot code
- Commonly used discrete random distribution
- 软件测试工程师的5年之痒,讲述两年突破瓶颈经验
- Analysis of JMM memory model
- The five-year itch of software testing engineers tells the experience of breaking through bottlenecks for two years
- 表空间创建管理及控制文件管理
猜你喜欢
Activity and fragment lifecycle
可以写进简历的软件测试电商项目,不进来get一下?
MATLAB提取不規則txt文件中的數值數據(簡單且實用)
Incremental database backup - DB incr DB full
What is the salary level of 17k? Let's take a look at the whole interview process of post-95 Test Engineers
AMS Series 1 - AMS startup process
历经一个月,终于拿到金蝶Offer!分享一下四面面经+复习资料
Intel 13th generation core flagship exposure, single core 5.5ghz
Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche
Software testing redis database
随机推荐
Android log system
ORACLE 11G 单机冷备数据库
Summary of the history of Mathematics
POI excel 单元格换行
How can UI automated testing get out of trouble? How to embody the value?
[VTK] vtkPolydataToImageStencil 源码解读
What is the salary level of 17k? Let's take a look at the whole interview process of post-95 Test Engineers
Analysis of JMM memory model
C语言日志库zlog基本使用
Google Earth Engine(GEE)——GHSL 全球人口网格数据集250米分辨率
Touch and screen automatic rotation debugging
高精度室内定位技术,在智慧工厂安全管理的应用
浅析-JMM内存模型
Solution: jupyter notebook does not pop up the default browser
Empire CMS no thumbnail smart tag (e:loop) two ways to judge whether there is a titlepic
MATLAB提取不规则txt文件中的数值数据(简单且实用)
php服务器 与redis交互大量CLOSE_WAIT分析
Function details of CorelDRAW graphics suite 2022
A simple method of adding dividing lines in recyclerview
Test what the leader should do