[ create a new paste ] login | about

Link: http://codepad.org/yORMquQm    [ raw code | output | fork ]

C, pasted on Jul 16:
#include <stdio.h>

#define X 5
#define Y 7

void output(char ary[][X]) {
  int i, j;
  for (i = 0; i < Y; i++) {
    for (j = 0; j < X; j++)
      printf("%c,", ary[i][j]);
    putchar('\n');
  }  
  putchar('\n');
}
  
void func(char ary[][X], int x, int y) {
  ary[y][x] = ary[y][x] - 'a' + 'A';
}

int main() {
  int i, j;
  static char a[Y][X];

  /* initialize */
  for (i = 0; i < Y; i++)
    for (j = 0; j < X; j++)
      a[i][j] = 'a' + i + j;

  func(a, 0, 1);
  output(a);
  func(a, 2, 3);
  output(a);
  func(a, 4, 5);
  output(a);

  return 0;
}
/* end */


Output:
a,b,c,d,e,
B,c,d,e,f,
c,d,e,f,g,
d,e,f,g,h,
e,f,g,h,i,
f,g,h,i,j,
g,h,i,j,k,

a,b,c,d,e,
B,c,d,e,f,
c,d,e,f,g,
d,e,F,g,h,
e,f,g,h,i,
f,g,h,i,j,
g,h,i,j,k,

a,b,c,d,e,
B,c,d,e,f,
c,d,e,f,g,
d,e,F,g,h,
e,f,g,h,i,
f,g,h,i,J,
g,h,i,j,k,



Create a new paste based on this one


Comments: