最好是比较相同长度的两个int数组的方式? [英] Best way to compare two int arrays of the same length?
本文介绍了最好是比较相同长度的两个int数组的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是比较INT数组b和c用最好的方式:
what is the best way to compare int arrays b and c with a:
int a[] = {0,1,0,0,1};
int b[] = {0,1,0,0,1};
int c[] = {1,1,0,0,1};
b和c都只是例子,假定它们可以是0和1的任意组合。
b and c are just examples, assume they can be any combination of 0s and 1s.
我试图探测阵列相同的一个。我用Google搜索了一会儿,并没有找到一个满意的答案。
I am trying to detect arrays identical to a. I have googled this for a while and have not found a satisfactory answer.
这是一个初学者的问题,我知道了,谢谢您的耐心等待。
This is a beginners question I realise, thank you for your patience.
推荐答案
使用标准的 memcmp
函数从<文件string.h>
。
memcmp(a, b, sizeof(a)) == 0
每当 A
和 B
都是平等的。
这篇关于最好是比较相同长度的两个int数组的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文