0 like 0 dislike
13k views
翻譯的工作有時候是依翻譯的字數來計價的,請設計一個程式計算一個句子中有幾個單字,在一個句子中被標點符號或是泛白字元隔開的可視為一個單子。

輸入說明:輸入會包含英文字母、數字以及標點符號,當程式遇到句點(.)時代表輸入結束。

輸出說明:請輸出一個整數代表輸 入的句子當中包含幾個單字。

輸入範例:

According to Josephus' account of the siege of Yodfat, he and his 40 soldiers were trapped in a cave by Roman soldiers.

輸出範例:

22
[Exercise] Coding (C) - asked in 2016-1 程式設計(一)AD by (18k points)
ID: 18072 - Available when: Unlimited - Due to: Unlimited

reshown by | 13k views

96 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
*** ***** ** * * ** * c ;
** * ** * ** * *** ** count=0 ;

    
** * *** *** ** * * ** ** *** * * *
**** * * ** * * ** ** *
***** * ** * * * *** **** * **
* * * *** * * * * * ***
** * * * * * ** ** * ** * * **** ** * ** ** * ** *
**** ** ******* ** ** * ******* ** ** **** * ** * * ')count++;
* * **** ** * * ****
** ** * * * ***** * * *
** * ** * ****** * * * *** *
** ** ** * * ** * ** * * *** **
*** * ** * * ** ** * 0;

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>

#include<stdlib.h>

int main()

{

    int i=0,n=0,s=0;

    char a[999],k[2];
** * **** ** ** * * ** ** ****** ** ** *** * * **** **
* * ** * * * * ** *** **** * ** ***** *

    */

    while(a[i-1]!='.')

    {
***** ** *** ** ** * * * * ** * * * * ** ** *** *** *** *** * ** * * * **** **
* *** *** * **** ** * *** * * ***** * * ** **** * * * * **** ** *
*** * * * * * ** ** * * * *** * **** ** * * * ** * *
******* * * ** ** *** **** * * * * * ** * * * **** * ** ****** ******* ** * * * ** * * ** ****** && a[i]<=57))
**** * *** * * * *** * * * * * *** * ** * * ******* *** ** * * * * *** ** ******** ** *** * * * ** ** *
* * * * *** * * ** ** * ** * ***** ** * **** * **** * * * * * *** ** * * * * * ** * * * * *** * ** * * * * *** * * * **** ** * ** * * * * **** ** ****** ' || a[i-1]==',' || a[i-1]=='\n' )n++;
** ** * * ** * *** * *** * * * * * ** * * ** ** ** ** * ** * **** * *** * * * * ** * * *** * ** ** * **
*** * ** ***** *** *** * * ** ** * * ** * * * * * *** *** * * * * * * *** * ****** ** *** ** ** **** ****** if((a[i]>=65 && a[i]<=91)||(a[i]>=97 && a[i]<=123))
* * * * * *** * * ***** * ** * * ** * * ** * * ***** * *** ** * * * * *** **** * *** ****** * *
* * * ** * *** * * * * ** * * ***** * *** * * * * * ** * * **** *** ** * * * *** * * *** * * *** ** *** ** * ** * * * ** ** * *** ** * ** * ** * * *** * * *** ** *** ** * * * * ' || a[i-1]==',' || a[i-1]=='\n')
* * * * * * ** ** ** * *** ** **** ** ** * * * **** * * * * * * ****** **** ** *** * * * * * * ** * *** * ** *** * * * * * ** * * ** ** *** * *** ** * * **
** ** ****** * * * * ** * * *** ** *** * **** * * * ** * ** * * *** *** ** * *** ** ** * **** *

* *** * ** * *** ** ** * * *** ** * * * * * * ** * *** * ***
* *** ** ** ***** * * ** * ** * ** * * ***** *

    }

    printf("%d",n);
* * * ****** * *** *** * * *** * *** ** * * *** **

}
answered by (-38 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>

#include<stdlib.h>

int main()

{
**** * **** ** **** **** i=0,n=0,s=0;
** * ** * * * * ** * ** a[999],k[2];
* ** *** ** *** * **** * * ** * ** * ** ** * * * **
* ***** ** ** * * * * *** ** ** * *

    */
*** *** ** * *** * * * * * * * *

    {
* * ***** ** ** * * * *** * ** * **** *** * * * *** ** * ***** ** * * ** *
** ** * * * ** * * * * ** *** * * ********* **** * * * **** * && a[i]<=57))
*** * * *** ** *** ** **** * ***** ** * * * * **** * *
* *** ***** * **** * * * * * **** ** *** ** ***** * **** * * ** * ** * ** *** *** ***** *** ** * ** ** ** * * * *** * ** ' || a[i-1]==',' || a[i-1]=='\n' )n++;
* * ** ** * * ** *** * ** * * ** ** ******* ** * *
** ***** * * ** ** * ** *** * * * * * *** ** * * *** * * *** ***** * * if((a[i]>=65 && a[i]<=91)||(a[i]>=97 && a[i]<=123))
* * * * * * *** ******* * ** * * ** *** *** * **** ** *
* * * * * * * *** **** * * ***** * * ***** ** * * **** * *** * ****** * * * ** * * * ****** * * * * * ' || a[i-1]==',' || a[i-1]=='\n')
** * * ** * ** ** * **** * * * *** * * *** * * ******* ** ****** * ** ** *** * *** **** ** * ** ** ** * *
************ * * *** * * ** ******* * ***** * * ** * *
** ** **** * **** * *** * *** * * * ** * * * ** * * *** ** ** *** ** *

    }
* * * * *** * *** ** ** ** * * **
** ******* ** * ** * * **** * * * **

}
answered by (-38 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>

#include<stdlib.h>

int main()

{

    int i=0,n=0,s=0;
* * * * * * * ****** * ** a[999],k[2];
* * **** * ***** ** ** ** * ** ** ** *** ** * * *
* *** ** * ********* * * ** * ** ** * *

    */
* * * * * ** * ***** * **** * * * *

    {
* **** ** *** ***** ** **** * ** * *** ** * ***** * * * *** * ** * ****
* * *** * **** ** * * ** ** * ** *** * *** *** ** * * * * ** && a[i]<=57))
*** *** *** **** * ** * * * * ** * * ** *** * * * * **
* * * ** ** * * * * ** **** *** *** ** * * ******** ***** ** *** * * *** * *** * * ** * * * **** ** **** * * ** * * * **** ** * * ')n++;
***** **** **** ** ** ******** * * **** ******* ** ** * ***
* **** * * * * ** **** * **** * * * *** * **** * * * * * * if((a[i]>=65 && a[i]<=91)||(a[i]>=97 && a[i]<=123))
*** * ** * * * **** ** * * ** ** ** * * ** ** *** ** *
**** ** * ***** ****** *** * * * ** * * ** *** * ** *** ** * ** **** ** * * * *** **** * **** * * ***** * *** **** * * * **** **** ****** * ' || a[i-1]==',')
** * ** ** ***** * * * ** * * ** ** **** * * ** * ******** ** * * ** * * ** * * ** * ** * *** ** ** ** * * *
*** * * * * *** * * ** **** ** ** ** * * * * * * ** * * *
* ** ** ** ** *** * ** ** * ** ** **** * * * * *

    }
** **** ** * * * * * ** *** ****
*** * * *** **** ** **** * * * * **

}
answered by (-38 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

#include<ctype.h>





int main ( void )

{
* * ** ***** *** * * c ;
* * * * ***** * ** * * **  digit=0,alphabet=0,other=0,a;
** **** ** * *** ** * ** * *** ** * * *** * *
* * *** *** ****** * c != '.')
* * ** * * * * * ** **
** * * * ** *** ** ***
* * * * ** * * * (isalpha(c))
** ** ** * **** * * * ** * * *
** * ********* * ** * ***** *
** * ** * * * * * ** * * if(isdigit(c))
* *** ** * * **** ** * **** *
*** ** * ***** ** ***
****** * * * *** * *** ***  
*** ***** ** * ** ** ** *****

    
* ** ***** * * ** * *** *** * * ***** *** *** * ****** ** * ** *
* *** * **** ** * ** * ** ** * * *
*** ** ******* ***
* *** ** * ** ** *** ** *
** * ** ** * * * ** * ** * * * * *
* * ** ****** * **** ** ( "%d",a);
** ******* **** * ** *
** * **** * ** * * * ** ** ** * * ** * **
* *** ** * *** *** 0;

}
answered by (-186 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
*** *** * ** * * * ** c;
* ** ** ** * * * ** i=0,j=0,k=0;
*** ** ** *** * **** * ** ** **** * ** *


*** *** ****** ** * * * * * * ** *
* * ** * * ** *
* ** * * **** * *** ** ** * **** ** * *** *** ** ')
* * * ** * ** * ** * ***** ** ** ** * *** * ** * * ** **** * * * * * ** * ****
* * ** * * **** ** * * * * **** ** ****** * * *
*** *** * * ** * * * ** ** *** * **   


* *** * **** ** * *** ***** *** * ***** * ****** ** * * * **** ** * * ** * * * ** **** * * * * ** *

   }  

  

   
** ** * ***** **** * * *



* ** ** * * * *** *** ** ** ** **
** ** *** *** * * * **** ***** ** *
** * * * **** * * ** * * *** 0;

}
answered by (-284 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
*** *** * **** *** ** c;
* ** * ** * * * *** * i=0,j=0,k=0;
* * ** * * ** * * * ** ** * ** * **


***** *** ***** *
* * ** * *** ** * * * *****
* ** * *** * * * * ** ** *** ** * *** *** ** * ')
* **** ***** ***** * *** *** * ** * ** * ** * ** * * * ** *** *
* **** *** * *** ****** * **** ***** *** ** * *
* * **** * * ** * *** * **** *** *** * ** *   


** * * * ** * * * * ** ** * * ** * * ****** **** * * ****** *** *** ** * * ** ** * * *** * ****

   }  

  

   
* ***** * * ** ** *********



** * * * ***** * * ** ***
* ** * ** * * * ***** ** * * * * ** *
* * * *** * * ** * * * *** * 0;

}
answered by (-284 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
* * * *** * * ** c;
* * ** * * * * * i=0,j=0,l=0,k=0;
* * ** * * * * * * *** * * * **** **


** *** * **** * ** * ** *
**** * * * ***** *
*** *** ** * ** ** * **** * **** * * * * * ')
* *** * *** *** ** ***** * * ** * * * * * * * * * * ** * ** ******
** * * **** * ** ** **** * * * ** * *** *
** ** *** * ***** ** ** ** ** ** * **** * **   


*** * * * ** *** * * * ** * ** * * * ******** * * *** *** ** * * ** * * * *** *** **** * ** *** * *

   }  

  

   
*** *********** * * **** ** *

* * * * ******** * ***** **** ** ** * ***** *
* * * ** * *** * * * ***** ***
** * ** *** ** * * **** ** * * *****
** * * * ** ** ****** 0;

}
answered by (-284 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
* *** ** ** ****** ** ** * c ;
* * * *** ****** * * * * alphabet = 0 ;
* * ** ** * ** *** ** * * ******** ***
** * * ** ** *** **** && c!=10)
* ***** * * * **** ****
* * * ** ** * * * **** *** * * * * * ** * ** * * && c<91)
** * ** * * *** * * ****** * * * ** * **** * * * * * *** ****
*** * *** * ** ** *** ** ** && c<123)
** * ****** * ** *** **** * * ** *** ** ** *** ** **** * ** *** ** * *
* * *** * * **** **** * * ** * * * *** *** * * ** *** *  
*** ** **** ** * ****
** *** * *** * * ** *** * ** * *

    
* * * * ** ** *** ** ******* *** * **
* * ** * ** * ** * * * * 0;

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>

#include<stdlib.h>

int main()

{
** * * ** ** * * * * i=0,n=0,s=0;
** ***** *** * * * * * a[999],k[2];
* **** * * ** * ** * ** * ** * * * ** ***
** * ** ** * *** **** **** * *

    */
* * ** ** **** * * ** *** ***

    {
**** * * * * * ** * ** * ** ** ***** * ********** **** **** * ** * ** ** ** ** * * * * * *
* *** ** * * *** *** * * * * **** * *** **** * *** * * ** **** * * ** ** * * && a[i]<=57))
** * * * ******** * * ** * * * * * **** ** * ** * *** **
* ** * * ** *** ** * *** * * ****** ** ** * ** *** ****** * ** * **** *** * * ** * *** ** *** *** * ** * ***** * ** ** * ** * * ')n++;
* ** * * * * ** * *** * ** ** * * *** ** * * ** ** ***
* **** *** *** *** * * *** ** *** * **** * * * *** * * * * *** if((a[i]>=65 && a[i]<=91)||(a[i]>=97 && a[i]<=123))
* *** * * ** * *** * * * ** ***** *** * *** * ** **
* * **** * * * * ** ***** ** * * ** * * *** ** * ** ** ****** * * *** * * * *** ** * * * *** * * * *** ** * * ** * ** ** ***** * * )|| (a[i-1]>91 && a[i]<97) || (a[i-1]>123))
* * ** * ** ** * ** *** *** * **** * * * *** * ** * **** * *** *** **** * ** * *** * * **** * **** * *** * ** *
** * * ** ***** **** **** ** ** * ** **** * ** ** * * * * *****
* * *** *** ** ** ** **** * * * ** ** ******** ** * * ** *

    }
** ** ** *** ** **** **
* * * ** ** * * **** ** * * *
*** *** ***** * * *** * * * *** ** * ****

}
answered by (-38 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.165
©2016-2026

Related questions

0 like 0 dislike
5 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18074 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 1.9k views
0 like 0 dislike
13 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18069 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 2.7k views
0 like 0 dislike
67 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18068 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 9.2k views
0 like 0 dislike
11 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18065 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 2.9k views
0 like 0 dislike
0 answers
[Resource] asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18084 - Available when: Unlimited - Due to: Unlimited
| 7 views
12,783 questions
183,442 answers
172,219 comments
4,824 users