Commit 78939e84 by olpool

Delete kontrollt662.c

parent f523beda
Showing with 0 additions and 75 deletions
#include <stdio.h>
int sisestus();
int main(){
int i,j,n,b,temp;
n = sisestus();
int a[n][n];
int summa1[2*(n-1)];
for(i = 0; i < n; i++){
for(j = 0; j < n;j++){
printf("sisesta maatriksi liige %d %d \n", i, j);
scanf("%d", &a[i][j]);
}
}
//algab diagonaalidega paralleelsete liitmine
int z = 0;
int x = 0;
x = 0;
for(b = 0; b < n - 1; b++){
i = b + 1;
j = b + 1;
z = 0;
summa1[x] = 0;
do{
summa1[x] += a[z][i];
i++;
z++;
printf("x %d ja summa x %d \n", x, summa1[x]);
}while(i <= n - 1);
x++;
z = 0;
summa1[x] = 0;
do{
summa1[x] += a[j][z];
j++;
z++;
printf("x %d ja summa x %d \n", x, summa1[x]);
}while(j <= n -1);
x++;
}
// algab sortimine kasvavas j'rjekorras
for(j=0;j<2*(n-1);j++)
{
for(i=0;i< n-j;i++)
{
if(summa1[i+1]<summa1[i])
{
temp = summa1[i];
summa1[i] = summa1[i+1];
summa1[i+1] = temp;
}
}
}
for(i=0;i< 2* (n-1);i++)
{
printf("jada %d liige: %d \n", i, summa1[i]);
}
return 0;
}
int sisestus(){
int temp;
printf("sisesta ruutmaatriksi veergude ja ridade arv\n");
scanf("%d", &temp);
return temp;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment