public static void main(String[] args) throws IOException
{
mapNumber(0,7,25); // will print 1
mapNumber(0,7,31);// will print 7
mapNumber(0,7,20); // will print 4
mapNumber(0,7,9); // will print 1
}
public static void mapNumber(int start,int end,int noToMap)
{
int min = start;
int max = end;
int testNumber = noToMap;
int base = (max - min)+1;
int mappedNumber = testNumber % base;
System.out.println(mappedNumber);
}
}
1条答案
按热度按时间s5a0g9ez1#
根据图片。你的数字从0到7,然后再从0开始;所以我们有min = 0,max = 7。