#include <stdio.h>
#define SIZE 20
int mapping(int); // 선언을 하고 맨아래 정의
void main(void) {
int group[]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int loc[]={61, 127, 21};
int i;
for(i=0; i<sizeof(loc)/sizeof(int); i++)
printf("%d ", group[mapping(loc[i])]);
/*loc 배열을 20으로 나눈 몫에 해당하는 table을 3번 반복
1. 61/20=3은 table[3]의 5를 반환
2. 127/20=6은 table[6]의 3을 반환
3. 21/20=1은 table[1]의 7을 반환 */
}
int mapping(int addr){
int table[]={0, 7, 4, 5, 0, 2, 3, 1, 8, 0};
return table[addr/SIZE];
}
To embed this project on your website, copy the following code and paste it into your website's HTML: