// source code
#include <stdio.h>
#define ROWS 3
#define COLS 4
void sum_rows(int ar[][COLS], int rows);
void sum_cols(int [][COLS], int);
int sum2d(int (*ar)[COLS], int rows);
int main(void)
{
int junk[ROWS][COLS] = {
{2, 4, 6, 8},
{3, 5, 7, 9},
{12, 10, 8, 6}
};
sum_rows(junk, ROWS);
sum_cols(junk, ROWS);
printf("sum of all elements = %d\n", sum2d(junk, ROWS));
return 0;
}
void sum_rows(int ar[][COLS], int rows)
{
int r;
int c;
int tot;
for (r = 0; r < rows; r++) {
tot = 0;
for (c = 0; c < COLS; c++) {
tot += ar[r][c];
}
printf("row %d : sum = %d\n", r, tot);
}
}
void sum_cols(int ar[][COLS], int rows)
{
int r;
int c;
int tot;
for (c = 0; c < COLS; c++) {
tot = 0;
for (r = 0; r < rows; r++)
tot += ar[r][c];
printf("col %d : sum = %d\n", c, tot);
}
}
int sum2d(int (*ar)[COLS], int rows)
{
int r;
int c;
int tot = 0;
for (r = 0; r < rows; r++) {
for (c = 0; c < COLS; c++)
tot += ar[r][c];
}文章来源:https://www.toymoban.com/news/detail-409781.html
return tot;
}文章来源地址https://www.toymoban.com/news/detail-409781.html
到了这里,关于逆向-还原代码之duowei_array (Arm 64)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!