將乙個字元長串分出單詞(林大oj1002)

2021-07-09 11:56:52 字數 1267 閱讀 2042

有乙個用空格( )、逗號(,)或是句號(.)分隔的許多英文單詞組成的字串(分隔的空格可以是多個)。請編寫程式將這些單詞分開並輸出。

要求,在main函式中完成資料的輸入。在子函式中完成拆分單詞及統計個數。

put

輸入的資料可以有多組,首先第一行輸入乙個整數n,接下來是n行,每行是用空格、逗號、句號分隔的字串,字串的長度少於1000個字元,拆出的單詞的個數少於300個。

對於每組資料,首先 輸出每行字串分出的單詞(分出的各個單詞用空格分隔)。接下來輸出分出的單詞的個數。

2

good a day

i am a

3good morning. how are you, this is a desk

yellow blue red grey

hong se

1 good you. ke kkk kkkkk diek

good a day

3i am a

3good morning how are you this is a desk

9yellow blue red grey

4hong se

2good you ke kkk kkkkk diek

6

#include 

#include

#include

using namespace std;

int main()

{    char ch[1005];

int len,n,i,j,k,ans;

while(cin>>n)

{getchar();

for(j=1;j<=n;j++)

{k=0;ans=0;

gets(ch);

len=strlen(ch);

for(i=0;i

寫了好久啊  寫的有一些亂啊  真是  終於寫對了   哇哦!!!

乙個字元驅動

實現乙個基本框架 define notice fmt,args.printk kern notice scull fmt,args define error fmt,args.printk kern err scull fmt,args static init int scull init void...

將乙個字串逆序

這個題要我自己寫還不太有思路,可能不會想到寫三個函式,而且這個 也沒有執行出來 include include include pragma warning disable 4996 有乙個字元陣列的內容為 student a am i 請你將陣列的內容改為 i am a student 要求 不能...

c c ,輸入乙個字元

getch getche 和getchar 函式 1 getch 和getche 函式 這兩個函式都是從鍵盤上讀入乙個字元。其呼叫格式為 getch getche 兩者的區別是 getch 函式不將讀入的字元回顯在顯示螢幕上,而getche 函式卻將讀入的字元回顯到顯示螢幕上。例1 include ...