当前位置:网站首页>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
边栏推荐
- 2022-07-02: what is the output of the following go language code? A: Compilation error; B:Panic; C:NaN。 package main import “fmt“ func mai
- Oracle 11g single machine cold standby database
- ExecutorException: Statement returned more than one row, where no more than one was expected.
- Lecture 1 number field
- 历经一个月,终于拿到金蝶Offer!分享一下四面面经+复习资料
- 如何成为一名高级数字 IC 设计工程师(1-5)Verilog 编码语法篇:操作数
- Word line and bit line
- 如何让让别人畏惧你
- C语言日志库zlog基本使用
- Expandablelistview that can expand and shrink (imitating the list page of professional selection of Zhilian recruitment)
猜你喜欢

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

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

Software testing e-commerce projects that can be written into your resume, don't you come in and get it?

可以写进简历的软件测试电商项目,不进来get一下?

What are the strengths of "testers"?

Cause: org. apache. ibatis. builder. Builderexception: error parsing SQL mapper configuration problem analysis

Balance between picture performance of unity mobile game performance optimization spectrum and GPU pressure

Encapsulate a koa distributed locking middleware to solve the problem of idempotent or repeated requests

00后抛弃互联网: 毕业不想进大厂,要去搞最潮Web3

php服务器 与redis交互大量CLOSE_WAIT分析
随机推荐
Software testing (test case) writing: vulgar, native and skillful
ExecutorException: Statement returned more than one row, where no more than one was expected.
Bi skills - permission axis
我对测试工作的一些认识(资深测试人员总结)
BI技巧丨权限轴
读书笔记:《心若菩提》 曹德旺
如何成为一名高级数字 IC 设计工程师(1-4)Verilog 编码语法篇:表达式
I have been doing software testing for three years, and my salary is less than 20K. Today, I put forward my resignation
Solution: jupyter notebook does not pop up the default browser
英特尔13代酷睿旗舰曝光,单核5.5GHz
Incremental database backup - DB incr DB full
POI excel 单元格换行
Internet Socket (非)阻塞write/read n个字节
After 8 years of industry thinking, the test director has a deeper understanding of test thinking
[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
Android log system
(二)进制
Cause: org. apache. ibatis. builder. Builderexception: error parsing SQL mapper configuration problem analysis
公司测试部门来了个00后卷王之王,老油条感叹真干不过,但是...
AIDL