Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void fill(int **A,int r, int c)
- {
- int i=0,j=0;
- for(i=0;i<r;i++)
- {
- for(j=0;j<c;j++)
- {
- A[i][j]=rand()%100 +1;
- }
- }
- for(i=0;i<r;i++)
- {
- for(j=0;j<c;j++)
- {
- printf("%5d",*(*(A+i)+j));
- }
- printf("\n"); printf("\n");
- }
- }
- void zad36(int n)
- {
- int ** aa=malloc(n*sizeof(int*));
- int i,j;
- for(i=0;i<n;i++)
- {
- aa[i]=malloc(n*sizeof(int));
- }
- fill(aa,n,n);
- int *niz=malloc(n*n/2*sizeof(int));
- int br=0;
- for (i=0;i<n;i++)
- {
- for(j=0;j<n;j++)
- {
- if(i>j && (i+j)<n-1) //i>j ispod glavne a drugi uslov je ispod sporedne :)
- {
- niz[br]=aa[i][j];
- br++;
- }
- }
- }
- int rez=-100000;
- for (i=0;i<br;i++)
- {
- if (niz[i]>rez)
- rez=niz[i];
- }
- printf("\n"); printf("\n"); printf("\n");
- for (i=0;i<br;i++)
- {
- printf("%5d",*(niz+i));
- }
- printf("\n"); printf("\n");
- printf("%d\n",rez);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement