2 喜歡 0 不喜歡
7.5k 瀏覽
計算字數

在英文中,被空白隔開的就會算是一個單字,所以

This is a pen.

這個句子中共有4個單字,請寫一個程式,計算輸入的句子共有多少個單字

輸入說明:

輸入一個句子,輸入會以一個句點.作為結束

輸出說明:

輸出一個正整數,表示輸入的句子共有幾個單字

輸入範例:

This is a pen.

輸出範例:

4
[練習] Coding (C) - 最新提問 分類:2017-1 程式設計(一)AD | 用戶: (18k 分)
ID: 33762 - 從幾時開始: 無限制 - 到幾時結束: 無限制

修改於 用戶: | 7.5k 瀏覽

24 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include ** * ** * *
#include ** * * *** * * ***
#include *** ** ** **


int main()
{
** ***   int n;
***   int i,k,len;
**** ***   char * * ** ** *** * * ****** * ** ** * *** ** ** * * ** *
* *   char *p;
* ***   int * ** ** ******
****   * *** * * * *
*** * *   {
* * *       ** * **
* * **       * * *
* *       ****
* **       ****** * *
**** * ** ** ** ** * * * ** ** **
*** ***** * * * ** * * * ****** * * *** * * ** * *** * ** *** *
* **** * * * ** *********** ** ** * * *** * *** * * {
** * ** **** *** * ** * ** *** ** * * ** **       * * *** ****
***** ** * * ** * ** * *** * * *** ** ***   *     * break;
* * * ** * *** ** ** * * * ** ****** * ****   }
*** * ** * * * ** *** * ** *** ** * **** * ** ** **
* * * * ** * * * * ****** * * * * ** ** ** {
****** * ** ***** * **** ** * * *** *** * * ***** * * * *   ** * ***   * ** * ***
* ** * ** ** ** ************ ** *** * * ****** *** *   }
* * * * * *** ** * ***** ** **** *** ** **** **** * **** ******* * *
* ******* * **** ** * **** * ** * ** ********
** *** * *** * ***** * * **** **** * * ***** **** * ***** * *
** * ** * ** ** *** ** ** * * ***** ** *** *
* * * ** * * *** ** ****** * ** * * ** * ** * *** * ** * * * * ******* ** * ** );
** * *** *** * **** *** ***** * ** * ***


**** *   }
**** **       return 0;
}
最新回答 用戶: (114 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
.
最新回答 用戶: (215 分)
0 0
prog.c:1:1: error: expected identifier or '(' before '.' token
 .
 ^
0 喜歡 0 不喜歡
內容已隱藏
**** *** * ***
** ** * ** * * *
int main()
{
* **** * * * char arr[100];
* *   *** ** ** * *
** ** * ** {
* * ** * ** ** *** * int * * * *
**** * * * * * * * **** * * * ***
* *** ** *** ** ** *** * {
* *** * * * ** * * ** *     * ** ')
* *   ****   * * ** * **** * * ** ** ** count++;
* * ** ** * * * *** ***** * * * *
** * * * * *** * * ** **** * ** **** ** * * **** break;
* ** **** * * * ** ** ** }
* * * * ** ** * * ** * * * * * * * * **
* * * ** }
* * ** return 0;
}
最新回答 用戶: (100 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
** *** ** * *
* *** * ***** **
int main()
{
* *** * *** char arr[100];
** *   ** ** *** ** ****
* ** * * {
** * ** ** ** ***** * * ** int * * * * * * * *
* * ** * * * * * * * **** * * **
**** * ** *** * *** * {
*** * ** * *** ** * *     *** *** ')
*** ****   ** *   * * * ** **** * * ** count++;
* * ** **** *** * ** * * * ***** * * ** *
* **** * * *** * *** * * *** * * * **** * * break;
***** ** * ** *** ** }
* **** *** * * * * * * * * ** ** * * *
* **** * * }
* ** *** * return 0;
}
最新回答 用戶: (100 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
** ***** ** * * *
**** * ** *** *
int main()
{
* **** * * char arr[100];
* ***   **** ** * * *
* * **** **** {
** * * *** int * ** * ** *
* * * * * * * * ** *** * * ******
* * * ****** * * * * ** {
* ** * ** * ******     * * ** ')
** *   * *****   ** ** ****** * * * * * * ** count++;
***** * * * * * * * * * *** * * ****
* ** ** ** * * * *** * * ** * * * * ** ** * break;
* * ** ** * **** ** }
* **** * * * * * * *** * * * * * ** ** *
* *** ******* }
* *** ***** return 0;
}
最新回答 用戶: (100 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
** * ** ** ****
int main()
{
 int i,x=1;
 char a[1000];
* * * **** ** **
**** * * * * *
 {

** ** * ** * * * **** * * **** ')
* **** * * *** ** * ** * * * **
* * ** ** **** * **** * *** * * *** **
** ** * * ** * *** * *** *
** * * * * *** * *** ***** ** * *
* *** ** * *** *** * ******* * * * *** * ** *****
 }
* *** * * * * * * * *
 return 0;
}
最新回答 用戶: (236 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
   int i,j=1;
**** * * * * * ** * str[1000];
* ** * **** * * * *** * *** * *
***** * * ** * * *** *** *******
   {
** ****** ** *** * * **** ** * *** ** ')
* ***** * ** * *** * ** **** * ** * *** *** ** *
* * *** ***** * *** * ***
** * * * * * ** * * ** ***** ** ****
** ** *** * * ** * ** *** ** *** ** *** ** * * *
** * * * * *** ** * * *
** ** ** * *** *
* ** ****** *** *** * * * ** ** **** *

 return 0;
}
最新回答 用戶: (172 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <string.h>

int main(){
* ** * ** ***** * * * ***** * ** ** * * ** *** **** * ** ** ** *
    int n=0,i=0;
* *** * **** * * * * ** * *
    char s1[1000];
* *** * * * ** ***** * ** ** **
** ** * *** * ******* *** * ** * ** * * **
* **** * **** ** ** ** * to judge the string
    int flag=0;
* *** * * ***** * **** ** * * * ** * **
    int k=strlen(s1);
* * ** ** * * ** ** *** * *
* ** * * * ** **** ** * * * ** * * *
*** ** ** ** ** ******* *** * *** **** * **** ** * ** * ** * * * * * * * **** *** * * ** * * * * * * **
* * * ** * ** **** * ****** * *** *** * ** ** *** *** * * ***** * * ** *
***** * * *** ** * ******** * **** * * * ** *
* ** *** * ****** * **** ***** ** * * **
* * ** * *** * * *** * *** * * * **** * ** * *** * *** * * *
* *** * ****** * ** * * *** * *** *** ** ** **** * ***** ***** * * ** * * * *
****** * **** * ** **** * ** *** ** * * * * **** * * * *** * ***** * * * * **** ******* ******* *
** *** *** * * ** ** * * ***** * **** ****** * * * * * *
* **** * * * ******* * *** * * ***
    }
最新回答 用戶: (212 分)
修改於 用戶:
0 0
prog.c: In function 'main':
prog.c:10:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(s1);
     ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccr4cALP.o: In function `main':
prog.c:(.text+0x39): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:26:5: error: expected declaration or statement at end of input
     }
     ^
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <string.h>

int main(){
    
* * * *** * * n=0,i=0;
    
* * ** * *** * **** ** s1[1000];
    
** * * ** ** ** ** * ** *** * * *** **
    
* *** * ***** ** ** **** flag=0;
    
* * * **** * * **** * ** * k=strlen(s1);
    
* ****** *** ** * ** ** ** * ** ***
***** * * *** ***** *** * * * **** *** ** ** **** ****** *** * **** ** **** **** * * * * * ** * **** ***** *** ****
* ** * * * * ** ** ** *** * ** ** *** *** ** ****** * ** ******
** ** * * * ** * * *** *** * ** * ***** * * * * * *
* *** ** *** * ** * * ****** * * * * ** ** * *
****** * * ** * *** ** * ****** **** **** * ** ** ** **** **** **
*** * * * * * * * ** *** *** **** ***** * * * ** * **** * * * *** * ** * * * * **
**** ** * * * **** * * ** * * **** *** * * * * *** * ** * ***** ***** * ** *****
*** ** **** * **** * ** * *** **** *** * ** * *** ** * ****
* **** **** * *** * * ** * * * * * *** *
** * *** * ** * ** *

* * * ** * *** *** *** ** * ** ** * ** *
* *** * ****** ** ** **** * 0;
}
最新回答 用戶: (194 分)
修改於 用戶:
0 0
prog.c: In function 'main':
prog.c:7:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(s1);
     ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccJQH56O.o: In function `main':
prog.c:(.text+0x39): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:7:11: warning: format not a string literal and no format arguments [-Wformat-security]
     scanf(s1);
           ^~
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
* * * * * * **
** * * ** * **** *
int main()
{
* ** * * * * char ****
***** * * *** int **** = 1;
* * * ** * * * * * ** *
** **** * * * * for (j = 0 ; str[j] != * * )
* {
* *** **** * * ** ** ***** *** * * * == ' ')
* ** * * *** ** * *** ** *
* ** * ** ** **** * ** **** * *** ***** = count + 1;
* ** * *** * * ** ** * *** * * **
* *** * }
* * * ** *** *** * ********
** **** ** * return 0;
}
最新回答 用戶: (209 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.164
©2016-2026

相關問題

3 喜歡 0 不喜歡
20 回答
[練習] Coding (C) - 最新提問 11月 16, 2017 分類:2017-1 程式設計(一)AD | 用戶: Shun-Po (18k 分)
ID: 33758 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 6.9k 瀏覽
3 喜歡 0 不喜歡
22 回答
[練習] Coding (C) - 最新提問 11月 16, 2017 分類:2017-1 程式設計(一)AD | 用戶: Shun-Po (18k 分)
ID: 33757 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 8.6k 瀏覽
3 喜歡 0 不喜歡
9 回答
[練習] 對錯二選一 - 最新提問 11月 16, 2017 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 33763 - 從幾時開始: 2017-11-16 14:00 - 到幾時結束: 2017-11-16 14:30
| 1.5k 瀏覽
3 喜歡 0 不喜歡
6 回答
[練習] Coding (C) - 最新提問 11月 30, 2017 分類:2017-1 程式設計(一)AD | 用戶: Shun-Po (18k 分)
ID: 34979 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 3k 瀏覽
3 喜歡 0 不喜歡
5 回答
[練習] Coding (C) - 最新提問 11月 30, 2017 分類:2017-1 程式設計(一)AD | 用戶: Shun-Po (18k 分)
ID: 34978 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2.9k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶