比较两种不同长度的阵列 [英] compare arrays of two different lengths

查看:140
本文介绍了比较两种不同长度的阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Android上的一个程序,将比较使用手势点手势的相似性。我有两个数组是这样的:

I am developing a program on Android that will compare the similarity of Gestures using Gesture Points. I have two arrays like this:

gest_1 = [120,333,453,564,234,531]
gest_2 = [222,432,11,234,223,344,534,523,432,234]

我知道有没有办法来动态调整阵列中的任何一个,那么,有没有办法为我用这些阵列来比较这两种手势和返回的相似性?

I know there is no way to dynamically resize either one of the arrays, so is there any way for me to compare both these gestures using these arrays and return the similarity?

请注意,在阵列中的数据都只是随机输入了。

Note that the data in the arrays are just randomly typed out.

推荐答案

您可以尝试这样的事:

  List similarities = new ArrayList();
  for(int i = 0; i < Math.max(gest_1.length, gest_2.length); i++){
    if (gest_1[i] == gest_2[i])
       similarities.add(gest_1[i];
  }

这篇关于比较两种不同长度的阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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