1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <stdio.h> #define SIZE 10 int main(void) { int key, i, flag, idx; int list[SIZE] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }; printf("[ "); for (i = 0; i < SIZE; i++) { printf("%d ", list[i]); } printf("]\n"); printf("Ž»öÇÒ °ªÀ» ÀÔ·ÂÇϽÿÀ:"); scanf("%d", &key); flag = 0; for (i = 0; i < SIZE; i++) { if (list[i] == key) { flag = 1; idx = i; break; } } if (flag == 1) printf("Ž»ö ¼º°ø À妽º= %d\n", idx); else printf("Ž»ö ½ÇÆÐ µ¥ÀÌÅÍ = %d\n", key); return 0; } | cs |