본문 바로가기
프로그래밍 C

쉽게 풀어쓴 C언어 익스프레스 프로그래밍 10장 3번

by MAKING CHA 2019. 11. 14.
반응형

#include <stdio.h>
#define SIZE 10

int array_equal(int a[], int b[],int size);


int main(void) {
int result = 0;
int a[SIZE] = { 0,1,2,4,5,6,7,8,9 };
int b[SIZE] = { 0,1,2,3,4,5,6,7,8 };

result = array_equal(a,b,SIZE);

if (array_equal(a,b,SIZE) == SIZE)
printf("두 배열이 같습니다.\n");
else
printf("두 배열이 다릅니다.\n");

 

return 0;

}

int array_equal(int a[], int b[],int size) {
int result = 0;

for (int i = 0; i < size; i++) {
if (a[i] == b[i])
result += 1;
else

result += 0;
return result;
}


}