728x90
반응형
문제 : http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=245&sca=10f0
strstr함수 활용
https://dojang.io/mod/page/view.php?id=371- 코딩도장 strstr설명
문제
100개 이하의 문자로 구성된 한 개의 문자열을 입력받아서 그 문자열에 문자 'c'와 문자열 "ab"의 포함여부를 "Yes", "No"로 구분하여 출력예처럼 출력하는 프로그램을 작성하시오.
입력 예
abdef
출력 예
No Yes
코드 :
# include <stdio.h>
# include <string.h>
int main()
{
char c[101]={0,};
scanf("%s",c);
if(strstr(c, "c"))
printf("Yes ");
else
printf("No ");
if(strstr(c, "ab"))
printf("Yes ");
else
printf("No");
return 0;
}
728x90
반응형
최근댓글