R
R
Ramazan Tolegenov2020-03-19 21:54:42
C++ / C#
Ramazan Tolegenov, 2020-03-19 21:54:42

How to make a block diagram for a matrix in C language?

Hello everyone, I have the following task: “Given an integer square matrix. Determine the minimum among the sums of the diagonal elements parallel to the main diagonal of the matrix." I have the code but I am having problems with the flowchart, can you help me with the flowchart or give me advice? thanks in advance here is my code:

#include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #define N_MIN -3
 #define N_MAX 5
 int main(int argc, char *argv[]){
 int s,i,j,k,l,s1,t2,t1; 
 int a[5][5];
 srand(time(NULL));
 for(i=0;i<5;i++){
 for(j=0;j<5;j++){
 a[i][j]=rand()%(N_MAX-N_MIN+1)+N_MIN;
 }
 }
    for(i=0;i<5;i++){
    for(j=0;j<5;j++){
    printf("%3d ",a[i][j]);
 }
    printf("\n");
 }
    k=0;
    s=0;
    l=0;
    for (i=0; i<5; i++){
    for (j=0; j<5; j++){
    if (a[i][j]>=0){
    if(a[i][j]%2==0)
    l+=a[i][j];
    k++;
 }
 }
    if (k==5){
    l=l;
 }
    else {
 l=0;
 }
    s=s+l;
    k=0; 
 }
    s1=a[0][5-1];
    for(i=1; i<5; i++){
    t1=t2=0;
    for(j=0; j<5-i; j++){
    t1+=a[i+j][j];
    t2+=a[j][i+j];
 }
    if(t1<s1) s1=t1;
    if(t2<s1) s1=t2;
 }
    printf("vivod %d %d\n", s,s1);
    return 0;
 }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question