코딩/Language Coder
604 : 문자열2 - 자가진단3
pikapika
2020. 4. 17. 01:14
[코드]
#include <stdio.h>
#include <string.h>
int main()
{
char str[10][20];
char c;
for(int i=0; i<10; i++)
scanf("%s", str[i]);
scanf(" %c", &c);
for(int i=0; i<10; i++)
{
if(str[i][strlen(str[i])-1] == c)
printf("%s\n", str[i]);
}
return 0;
}
※ "scanf("%c", &c);"는 채점이 제대로 되지 않는다. 이럴 때는 "%c"앞에 공백을 넣어주면 개행문자를 무시하는 역할을 하기 때문에 "scanf(" %c", &c);"로 코드를 고쳐주면 제대로 들어간다.