Created
December 11, 2018 06:56
-
-
Save claudianus/6561ecd44d37b9ec41cce081bd339073 to your computer and use it in GitHub Desktop.
question 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
struct info { | |
char name[5]; | |
char homeNumber[12]; | |
char phoneNumber[12]; | |
char email[100]; | |
} info; | |
int main(void) { | |
struct info infoArr[] = { | |
{ | |
.name = "A", | |
.homeNumber = "135153", | |
.phoneNumber = "1636136", | |
.email = "[email protected]" | |
}, | |
{ | |
.name = "B", | |
.homeNumber = "13636613", | |
.phoneNumber = "613613163", | |
.email = "[email protected]" | |
}, | |
{ | |
.name = "C", | |
.homeNumber = "527", | |
.phoneNumber = "34343", | |
.email = "[email protected]" | |
}, | |
{ | |
.name = "D", | |
.homeNumber = "5727", | |
.phoneNumber = "324523", | |
.email = "[email protected]" | |
}, | |
{ | |
.name = "E", | |
.homeNumber = "25755347", | |
.phoneNumber = "124124", | |
.email = "[email protected]" | |
} | |
}; | |
char name[5]; | |
scanf_s("%s", name, sizeof(name) - 1); | |
_Bool found = 0; | |
for (unsigned i = 0; i < sizeof(infoArr) / sizeof(info); i++) | |
{ | |
if (strcmp(infoArr[i].name, name) == 0) { | |
printf("집: %s, 휴대폰: %s\n", infoArr[i].homeNumber, infoArr[i].phoneNumber); | |
found = 1; | |
break; | |
} | |
} | |
if (!found) { | |
printf("그런 사람 없다\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment