All pastes #272913 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-09 12:13 UTC
rendered paste body
int wormMatrix(char* file1)
{
 TMatrix matice1;
 int pokus = LoadMatrix(file1, &matice1);
  if (pokus == 1)
   {
    return 0;
   }
//printf("%d\n",matice1.matrix[1][1]);
 
 int i=0,j=0,p,x=0,posuv,prvek,radek=0,posuvpole=0;
 int r = matice1.rows;
 int c = matice1.cols;
 p = (r*c);
 int pole[p];
 posuv = matice1.matrix[0][0];

 printf("%d %d",r,c);
 printf("\n");

  for (i=0; i<r; i++)
   {
    for (j=0; j<c; j++)
     {
      pole[x] = matice1.matrix[i][j];
      x++;
     }
   }

  while (posuv>0)
  {
   prvek=pole[x-1];
   for ( i=x; i>0; i--)
    {
     pole[i]=pole[i-1];
    }
    pole[0]=prvek;
    posuv--;
  }

  while (posuv<0)
   {
    prvek=pole[0];
    for ( i=x; i>0; i--)
     {
      pole[x-i]=pole[x-i+1];
     }
     pole[x-1]=prvek;
     posuv++;
   }

  while (radek<r)
   {
    if (radek<=r-1)
     {
      for ( i=0; i<=c-1; i++)
       {
        printf("%d ",pole[i+posuvpole]);
       }
        printf("\n");radek++;posuvpole+=c;
       }
    else
     {
      continue;
     }

    if (radek<=r-1)
     {
      for ( i=c-1; i>=0; i--)
       {
        printf("%d ",pole[i+posuvpole]);
       }
       printf("\n");radek++;posuvpole+=c;
       }
    else
     {
      continue;
     }

   }

freeMatrix(&matice1);
 return EOK;
} // fce wormMatrix