请帮我 !这该怎么做 [英] please help me ! how to do this

查看:48
本文介绍了请帮我 !这该怎么做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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]


这篇关于请帮我 !这该怎么做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆