Răspuns :
Răspuns:
int nr,n,i,j,s=0;
cin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++){
cin>>nr;
if(i==j&&nr%4==0)
s+=nr;
}
if(s==0) cout<<"Nu exista";
else cout<<s;
Răspuns:
#include <stdio.h>
int main(){
int a[100][100],suma=0,n;
scanf("%d", &n);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
printf("a[%d][%d]=",i,j);scanf("%d", &a[i][j]);
if((i==j)&&(a[i][j]==4)){
suma+=a[i][j];
}
}
}
if(suma>0){
printf("%d", suma);
}else{
printf("Nu exista");
}
}
Explicație: