Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int array_compare(double *p1, double *p2, int comp1, int comp2) {
- if (comp1 != comp2) return 0;
- int i;
- for (i = 0; i < comp1; i++)
- if (*(p1 + i) != *(p2 + i)) return 0;
- return 1;
- }
- int main() {
- double array1[] = {1,2,3,4,5}, array2[] = {1,2,3,4,5};
- double array3[] = {1,2,3,4,5}, array4[] = {4,5,6,7,8};
- double array5[] = {1,2,3,4,5}, array6[] = {1, 2, 3};
- if (array_compare(array1, array2, 5, 5)) printf("1");
- if (array_compare(array3, array4, 5, 5)) printf("2");
- if (array_compare(array5, array6, 5, 3)) printf("3");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement