Notice
Recent Posts
Recent Comments
Creative Code
arrayCompare.c(두 배열 비교) 본문
#include <stdio.h>
int main(void)
{
int nums1[] = {1,2,3,4,5};
int nums2[] = {1,2,3,4,5};
/* if (nums1 == nums2) {--> 배열의 주솟값을 비교하는것이기 때문에 이는 무조건 false이다.
printf("nums1 and nums2 are equal\n");
} else {
printf("nums1 and nums2 are not equal\n");
}
*/
int i;
for (i = 0; i<5; i++){
if (nums1[i] != nums2[i]){
break;
}
}
if (i == 5) {
printf("nums1 and nums2 are equal\n");
} else {
printf("nums1 and nums2 are not equal\n");
}
return 0;
}
'C Programming' 카테고리의 다른 글
power.c(지수 계산하기) (0) | 2023.08.03 |
---|---|
pointerAndArray2.c(포인터와 배열의 관계) (0) | 2023.08.03 |
arrayAssignment.c (배열 복사) (0) | 2023.08.03 |
pointerAndArray.c(포인터와 배열) (0) | 2023.08.03 |
scoreGrade4.c(성적따라 학점부여) (0) | 2023.08.03 |