#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
char chWord;
int ntemp = 0;
int nMax = 0;
printf("enter the string : (EXIT : Ctrl+z)");
chWord = getchar();
while(chWord != -1)
{
chWord = getchar();
if(chWord == '\n' )
{
if(ntemp > nMax)
{
nMax = ntemp;
ntemp = 0;
}
else ntemp = 0;
}
ntemp++;
}
printf("longest voca's count : %d\n",nMax-1); // 널문자값으로 1씩 더 나오기 때문에 -1을 해줌.
return 0;
}
댓글 없음:
댓글 쓰기