#include "stdafx.h"
#include "iomanip.h"//
#include
struct word{
char c[30];
int n;
}w[1000];
void main(void){/*主程序*/
char b[30],Str[30000];
int i=0,m=1,k=0,flag=0,x=0;
cout << "Type a short text...\nStr=";
while(cin.get(Str[x]),Str[x++]!='\n');
Str[x-1]='\0';
x=0;
while(Str[x]){
if('A'<=Str[x] && Str[x]<='Z' || 'a'<=Str[x] && Str[x]<='z' || Str[x]=='-'){
b[i++]=Str[x];
flag=1;
}
else if(flag){
b[i]='\0';
flag=m=0;
for(i=0;i
m=1;
break;
}
}
if(!m){
w[k].n=1;
strcpy(w[k++].c,b);
}
else w[i].n++;
i=0;
}
x++;
}
for(i=0;i
cout << endl;
}
是指单词?有空格或者其他符号分割?例如 "Love is zero"这种?