我正在尝试编写一个比较2个数组的代码,一个大一个,一个小。较小的数组检查较大的数组上的任何值是否相同,并打印找到值的位置。
示例 小数组= {1,3,4} 大数组= {1,1,2,5,5,6,7,3}
溶液: 现场0发现1 在现场1找到1 等。
这是我设法废弃的java代码版本,
public class MipsPractice
{
public static void main(String [] args)
{
int [] arrayOne = {9, -17, 14, 9, -23, 8, -23, 9, 14, -17, 9};
int [] arrayTwo = {19, 8, 9, 0};
int arrayOneLength = arrayOne.length;
int arrayTwoLength = arrayTwo.length;
for(int i = 0; i < arrayTwo.length; i++)
{
for(int j = 0; j < arrayOneLength;j++)
{
if(arrayTwo[count] == (arrayOne[j]))
{
System.out.println("Found" + arrayTwo[j] + "at location " + j);
}
}
}
}
}
无论如何,请帮助我,我真的很困惑MIPS