Find the amount under and above the main diagonal EXAMPLE 1 2 3 4 5 6 7 8 9 above it will be 2 + 3 + 6 = 11 - correctly, and under 4 + 7 + 8 = 19, and gives 15 (7 + 8) Here is the code : `
#include <iostream> using namespace std; int main() { int S1, S2, i, j, N, a[10][10]; cout<<"N="; cin>>N; cout<<"ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ ΠΌΠ°ΡΡΠΈΡΡ Π \n"; for (i=0; i<N; i++) for (j=0; j<N; j++) cin>>a[i][j]; for (S1=i=0; i<N; i++) for (S2=j=0; j<N; j++) for (j=0; j<N; j++) //Π΅ΡΠ»ΠΈ ΡΠ»Π΅ΠΌΠ΅Π½Ρ Π»Π΅ΠΆΠΈΡ Π²ΡΡΠ΅ Π³Π»Π°Π²Π½ΠΎΠΉ Π΄ΠΈΠ°Π³ΠΎΠ½Π°Π»ΠΈ, ΡΠΎ Π½Π°ΡΠ°ΡΠΈΠ²Π°Π΅ΠΌ ΡΡΠΌΠΌΡ { if (j>i) { S1+=a[i][j]; } else { if (i>j) { S2+=a[i][j]; } } } cout<<"S1="<<S1<<endl; cout<<"S2="<<S2<<endl; return 0; }
S1=infor (S1=i=0; i<N; i++)(and similarly in the next cycle)? Do you understand that inS1zero is placed after at the beginning of each new line? - HolyBlackCatS1andS2not there, but before the cycles. - HolyBlackCat