如何反转数组中的数字

编程入门 行业动态 更新时间:2024-10-25 04:24:44
本文介绍了如何反转数组中的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 像我有3个数组,在第一个数组中,我有2个,我有2个,在第3个我有3个,我想将每个数组中的值复制到另一个数组,但在第一个元素中数组它应该有3个,在第2个2和第3个1 我尝试过: i完成了问题的第一部分,要求用户输入数组中元素的数量,并再次要求他输入数组中每个元素的数字

解决方案

从一张纸和一支钢笔或一支铅笔开始。将每个数组绘制为一组框,并在正确的位置添加数字。现在看看在逻辑步骤中需要做些什么才能从那里得到答案。在弄清楚时记下每一步,随时更新图表。完成后,您只需要将您编写的伪代码转换为您计划用于程序的任何语言。

拿一张纸和3个代币。 画3个方格,每个方格放1个标记。 这是你的起点 你要做的是旋转 取1个标记,将其移出正方形 现在1平方为空,你可以从另一个方格移动1个标记,重复 最后,将标记移到一边在自由广场。 这是你的程序的工作方式,简单地说'旁白'是另一个变量。

like i have 3 arrays and in the 1st array i have 1 in the 2nd i have 2 and in the 3rd i have 3 and i want to copy the values in each array into another array but in the 1st element in the 1st array it should have 3 and in the 2nd 2 and in the 3rd 1 What I have tried: i have finished the 1st part of the question which is asking the user to enter the number of the elements in the array and asking him again to enter the numbers in each element in the array

解决方案

Start with a piece of paper and a pen or pencil. Draw each array as a set of boxes, and add the numbers in the right places. Now see what needs to be done to get from there to the answer, in logical steps. Write each step as you figure it out, updating the diagrams as you go. When you have finished you just need to convert the pseudocode you have written into whatever language you plan to use for your program.

Take a piece of paper and 3 tokens. Draw 3 squares, put 1 token in each square. this is your starting point What you want to do is a rotation Take 1 token, move it outside of the squares Now 1 square is empty, you can move 1 token from another square, repeat And finally, move the token aside in the free square. this is how your program will work, simply the 'aside' thing is another variable.

更多推荐

如何反转数组中的数字

本文发布于:2023-06-04 08:32:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/493308.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组中   转数   数字

发布评论

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

>www.elefans.com

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