本文介绍了请帮我 !这该怎么做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1234567891011121314 例如: 输入5 - >输出:5 输入11 - >输出:0 输入19 - >输出:4 如何解决这个问题? 非常感谢
1234567891011121314 example: input 5 -> output : 5 input 11 -> output : 0 input 19 -> output : 4 how to solve this ? thanks very much
推荐答案创建一个数组(比如 int a [] )映射输入(数组项的索引)到输出(数组项的值)。 然后,对于每个输入 i ,你产生输出 a [i] 。 [update] 这很简单(绑定检查留给读者)。 Create an array (say int a[]) mapping input (the index of the array item) to the output (the value of the array item). Then, for each input i you produce the output a[i]. [update] It is really simple (bound checking left to the reader). int output(int input) { static int a[] = {1,2,3,4,5,6,7,8,9,1,0,1,1,1,2,1,3,1,4}; return a[input]; }
[/ update]
更多推荐
请帮我 !这该怎么做
发布评论