编程知识 cdmana.com

Why not add the value of Z [0] [0] to a two-dimensional array

#include<stdio.h>int n,sum=0;int z[3][3]={
   
   
   
   {
   
   
   
   3,6,8},{
   
   
   
   10,2,3},{
   
   
   
   7,1,9}};void niuma();int main(){    niuma();    return 0;}void niuma(){    int x, y;    for (x = 0; x < 3; x++)    {        for (y = 0; y < 3; y++)        {            if (x = y) { sum += z[x][y]; }        }    }    printf("%d", sum);}



Refer to the answer 1:

The first 17 That's ok :if (x = y) { sum += z[x][y]; } , x == y , One less. ‘=’ Number




Refer to the answer 2:

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/11/20211120201546593g.html

Scroll to Top