회문이란 거꾸로 읽어도 같은거이다.
예를 들어 "SOS", "level"같은것이 있다.
실행결과 예1
Input : level
output : 1
실행결과 예2
Input : baby
output : 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <stdio.h>
#include <string.h>
int main() {
int flag = 0;
char a[100] = { 0 };
printf("Input : ");
scanf("%s", a);
int len = strlen(a);
for (int i = 0;i < len/2;i++) {
if (a[i] == a[len - 1 - i])
flag++;
}
if (flag == len / 2)
printf("1");
else
printf("0");
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'School class' 카테고리의 다른 글
c언어)선형탐색, 이진탐색 [수업] (0) | 2019.10.11 |
---|---|
C언어)문자열 포함 확인[수업] (0) | 2019.09.23 |
C언어) 삽입정렬 (0) | 2019.09.06 |
C언어)버블정렬 (0) | 2019.09.06 |
c언어) 선택정렬 (0) | 2019.09.06 |