请帮我 !这该怎么做

编程入门 行业动态 更新时间:2024-10-28 16:19: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]

更多推荐

请帮我 !这该怎么做

本文发布于:2023-10-18 02:09:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1502772.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:帮我   怎么做   这该

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!