[ create a new paste ] login | about

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

novatech - C, pasted on Jan 15:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <time.h>
int s(int i, int j, int a,int b){
  return (i == 0 || j == (b-1)) ? \
  (a*b) - (1 + i + j) : (i == (a-1) || j == 0) ?\
  (a-1)*(b-1)-((a-i)+(b-j))+2 :\
  (a > 2 || b > 2) ? s(i-1, j-1, a-2,b-2) : 0;\
}   
int main() {
int x,y,a,b;
//srand((unsigned)time(0));
//while (!a||!b) { a = rand()%10; b = rand()%10; }
a = 5;b=6;
for (x=0;x < a;x++){ 
    for (y=0;y<b;y++) printf("%d\t",a*b-s(x,y,a,b)); 
    printf("\n\n"); 
}
return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
1	2	3	4	5	6	

18	19	20	21	22	7	

17	28	29	30	23	8	

16	27	26	25	24	9	

15	14	13	12	11	10	



Create a new paste based on this one


Comments: