【发布时间】:2011-04-01 12:57:18
【问题描述】:
假设我有一个类 RainbowColorsMapper,其构造函数为 RainbowColorsMapper(int n),其中 n>=2。现在我想要连续映射从红色到紫色的彩虹色,我使用mapper.getColor(int number) 方法获得,其中低值对应于红色端,高值对应于 n 到紫色端。如果 n = 2,mapper.getColor(0) 返回光谱最左边的颜色(接近红色),mapper.getColor(1) 返回最右边的颜色。与具有自动缩放的较大 n 相同。
我的问题:这可以相对容易地完成吗?如果可以,对算法有什么建议?
【问题讨论】:
-
Er: "RainbowColorsMapper(int n), where n>=2" and "mapper.getColor(1) 返回最正确的颜色"?你在说什么,威利斯?
-
“与更大的 n 相同,自动缩放”是什么意思?