C++判断两个数组相等的函数
时间: 2024-01-31 13:03:11 浏览: 164
C语言中判断两数组中是否有相同的元素
```c
#include <stdio.h>
#include <stdbool.h>
bool isEqual(int arr1[], int arr2[], int size) {
for (int i = 0; i < size; i++) {
if (arr1[i] != arr2[i]) {
return false;
}
}
return true;
}
int main() {
int arr1[] = {1, 2, 3, 4, 5};
int arr2[] = {1, 2, 3, 4, 5};
int size = sizeof(arr1) / sizeof(arr1[0]);
if (isEqual(arr1, arr2, size)) {
printf("Arrays are equal\n");
} else {
printf("Arrays are not equal\n");
}
return 0;
}
```
阅读全文