#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++) //loc 크기:3 int크기:4
printf("%d ", group[mapping(loc[i])]);
//loc[0]=61, mapping(61), table[61/20=3]=5 출력
//loc[1]=127, mapping(127), table[127/20=6]=3 출력
//loc[2]=21, mapping(21), table[21/20=1]=7 출력
//5 3 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: