티스토리 뷰

//단어를 입력하고 엔터로 구분하되, 컨트롤z를 입력하면 가장 긴 단어의 길이를 출력해쥼


#include <stdio.h>

int main(void)

{
    int ch;
    int length;
    int top_length=0;

    for(;ch=getchar(),ch!=-1;)
    {
        length=0;
        while(ch!='\n')
        {
            length++;
            ch=getchar();
        }
        if(length>top_length) top_length=length;
    }

    printf("가장 긴단어의 길이 : %d",top_length);
    return 0;
}


-------------------------------


father
mother
brother
school
this program is powered by koreamcp
strawberry
^Z
가장 긴단어의 길이 : 35

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함