當前位置:編程學習大全網 - 電腦編程 - 輸入壹行字符,用函數編程統計其中有多少單詞

輸入壹行字符,用函數編程統計其中有多少單詞

#include <stdio.h>

#include <ctype.h>

int main()

{ int n=0,st=1;

char c;

while ((c=getchar())!='\n')

{ if(isalpha(c))st=1;

else if(st)

{ st=0;

? n++;

}

}

n+=st;

printf("there are %d words.\n",n);

return 0;

}

  • 上一篇:基本的幾何圖形知識點。
  • 下一篇:c語言編程問題 如何逐個讀取數字
  • copyright 2024編程學習大全網