如果我有一个只存在很短时间的功能,那么使颜色列表保持不变会有所不同吗?
string getrandcolor(){
const string colors[5] = {"red", "blue", "green", "yellow", "purple"};
return colors[rand() % 5];
}
Run Code Online (Sandbox Code Playgroud)
注意:实际的颜色列表包含数百种颜色,而不仅仅是我展示的小样本,不确定这是否也有所不同.