# C語言題庫-077 輸入一行字符,統計其中有多少個單詞。 【參考答案】 ``` #include <stdio.h> main() { char str i ng[81]; int i,num=0,word=0; char c; gets(string); for(i=0;(c=string[i])!=’\0’;i++) if(c==’ ') word=0; else if(word==0) { word=1; num++; } printf(“There are %d word s in the line\n”,num); } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up