#include <stdio.h>

struct mas{int n; int a[10]; int s;} massiv,masstr[3];

int summauk(struct mas *x)
{ int i,s=0;
  for(i=0;i< x->n;i++) s+=x->a[i];
  x->s=s;
  return s;
}

int summass(struct mas &x)
{ int i,s=0;
  for(i=0;i< x.n;i++) s+=x.a[i];
  x.s=s;
  return s;
}
int summa(struct mas *x)
{ int i,k,s,ss=0;
  for(k=0;k<3;k++,x++)
    { for(s=0,i=0;i<x->n;i++) s+=x->a[i];
      x->s=s;
      ss+=s;
    }
  return ss;
}
void printstr(struct mas &m)
{ int i;
    puts("Iformation about struct");
    puts("  Maasiv  ");
    printf("Size of mssiv  %5d\n",m.n);
    for(i=0;i<m.n;i++)
       printf("%4d",m.a[i]);
    printf("\n Summa=%5d\n",m.s);

}
int main()
{int i,j;
    puts("__________Example N 1  ssylka_______________________");
    puts("Enter n<=10");
    scanf("%d",&massiv.n);
    printf("Enter %4d elementov massiva\n",massiv.n);
    for(i=0;i<massiv.n;i++)
        scanf("%d",&massiv.a[i]);
    printstr(massiv);
    summass(massiv);
    printstr(massiv);
    puts("____ Example N 2  ukazatel \nEnter   NEW maasiv_____________________");
    puts("Enter n<=10");
    scanf("%d",&massiv.n);
    printf("Enter %4d elementov massiva\n",massiv.n);
    for(i=0;i<massiv.n;i++)
        scanf("%d",&massiv.a[i]);
     printstr(massiv);
    summauk(&massiv);
    printstr(massiv);
    puts("____ Example N 3  Massiv of struct \nEnter   NEW maasiv_____________________");
    puts("____ Enter maasiv of struct_____________________");
    for(i=0;i<3;i++)
    {
        printf("_ Enter  %3d struct- maasiv___\n",i+1);
        puts("Enter n<=10");
        scanf("%d",&masstr[i].n);
        printf("Enter %4d elementov massiva\n",masstr[i].n);
        for(j=0;j<masstr[i].n;j++)
            scanf("%d",&masstr[i].a[j]);

    }
    puts("____ Massiv of struct__________ ");
     for(i=0;i<3;i++)
        { printf("___________Struct  %5d\n",i+1);
          printstr(masstr[i]);
        }
     int sumsum=summa(masstr);
     puts("____ Massiv of struct after sum__________ ");
      for(i=0;i<3;i++)
         { printf("___________Struct  %5d\n",i+1);
           printstr(masstr[i]);
         }
      printf("Summa summ =%5d\n",sumsum);
return 0;
}
