搜索和打印数组 [英] Searching and printing arrays

查看:86
本文介绍了搜索和打印数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在上Java课。

我们必须制作一个维数组。我做了什么。

但是我们必须得到用户输入,在数组中找到匹配的输入并打印另一方就是那个数组。我不知道必须搜索数组并获得响应。

示例:

I am taking a class in Java.
We have to make an dimensional array. Which I did.
But then we have to get the users input, find the matching input in the array and print the other party is that array. I do not know have to search the array and get the response.
Example:

String[][] states={
                        {"Alabama", "blue jay"},
                        {"Alaska", "mockingbird "},
};



因此用户输入Alabama然后程序会说


So the user would type Alabama and then the program would say

State: Alabama
State Bird: blue jay



有人可以指导我吗



我尝试过:



要列出的许多人...尝试使用用户输入正常打印


Could someone guide me please

What I have tried:

To many to list ... Trying to print normally by using the user input and more

推荐答案

访问二维数组是微不足道的,以获得行 r 和列 c ,使用
Accessing a bidimensional array is trivial, in order to get row r and column c, use
states[r][c]



例如


For instance

System.out.println(states[0][1]);

输出

Outputs

blue jay


我们不做你的作业:它是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是像你想的那么难!首先查看您的课程说明:关于用户输入,访问数组元素,循环(您需要两个嵌套循环),最后打印。我很确定最近所有这些都已经涵盖了!



如果您遇到特定问题,请询问相关问题,我们会尽力提供帮助。但是我们不会为你做这一切!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think! Start by looking at your course notes: about input from the user, accessing elements of arrays, loops (you'll need two nested loops), and finally printing. I'm pretty sure all of this is covered recently!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


我不是要你做我的功课。我的教授是垃圾,没有回应,我看了他给我们的东西。我被困了......这就是我在这里的原因。
I am not asking you to do my homework. My professor is garbage, does not respond and i have looked over what he has given us. I am stuck...that is why i am here.


这篇关于搜索和打印数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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