当前位置:网站首页>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
边栏推荐
- Definition and properties of summation symbols
- What kind of living condition is a tester with a monthly salary of more than 10000?
- The highest monthly salary of 18K has a good "mentality and choice", and success is poor "seriousness and persistence"~
- Summary of interview questions (2) IO model, set, NiO principle, cache penetration, breakdown avalanche
- Clion debug
- 嵌入式軟件測試怎麼實現自動化測試?
- [proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder
- Solution: jupyter notebook does not pop up the default browser
- 表空间创建管理及控制文件管理
- Struct function & function pointer
猜你喜欢

(二)进制

redis那些事儿

10. Nacos source code construction

AMS Series 1 - AMS startup process

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

MATLAB提取不規則txt文件中的數值數據(簡單且實用)

嵌入式軟件測試怎麼實現自動化測試?

公司测试部门来了个00后卷王之王,老油条感叹真干不过,但是...

Differences among norm, normalize and normalized in eigen

Error installing the specified version of pilot
随机推荐
Stack, monotone stack, queue, monotone queue
Latest sales volume of pinduoduo
嵌入式軟件測試怎麼實現自動化測試?
Software testing (test case) writing: vulgar, native and skillful
使用onvif协议操作设备
ExecutorException: Statement returned more than one row, where no more than one was expected.
C语言二维数组
ORACLE 11G 单机冷备数据库
Kotlin's use of the no Arg compiler plug-in in gradle
项目管理精华读书笔记(七)
Solve the problem that pycharm Chinese input method does not follow
在职美团测试工程师的这八年,我是如何成长的,愿技术人看完都有收获
【obs】obs的ini格式的ConfigFile
Hal -- writing hardware drivers
Expandablelistview that can expand and shrink (imitating the list page of professional selection of Zhilian recruitment)
Probability theory: application of convolution in calculating moving average
Summary of the history of Mathematics
What are the strengths of "testers"?
VPP三层网络互联配置
LeetCode 46:全排列