1. 목적
- 소문자로 변환 할줄 안다.
2. 문제
- 문장을 입력받아 대문자를 소문자로 나머지 문자는 그대로 출력하는 프로그램을 작성하라.
- 출력 화면
http://cakel.tistory.com
Press any key to continue
3. 이해
- 대문자를 소문자로 변환할줄 아는가?
- 문장을 입력 받을 수 있는가?
4. 코드
#include<ctype.h>
int main()
{
char input[255] = {0};
int i = 0;
gets(input);
while(input[i])
{
if(isupper(input[i]))
putchar(tolower(input[i]));
else putchar(input[i]);
i++;
}
putchar('\n');
return 0;
}
5. 해설
- 대문자인지 확인하여 대문자이면 소문자로 그렇지 않으면 그대로 출력하는 알고리듬입니다.
- 한글자씩 검사후 putchar로 출력합니다.
- 문자 속성 확인 및 변환은 ctype.h 라는 라이브러리에 있습니다.
6. 참고
- http://cakel.tistory.com/entry/2003년-기말-5번-대소문자-변경-2 : 유사 문제