我的想法是这样的,输入的这段英文,先存储到一个很长的一维字符数组里面,然后再定义一个字符串数组(或者二位字符串数组)。用循环去判别字符数组里面是字母的,就存起来,一旦遇到不是字母的,就进行下一个字符串的存储,存储到什么时候呢,存储到遇到的又不是字母的时候,直到那个一维数组全部都被遍历完为止。
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
using namespace std;
#include<cstdio>
#include<math.h>
#include<string>
using namespace std;
int main()
{
int n=0,lt,k=0;
char temp[5000];
gets(temp);
lt=strlen(temp);
while(n<lt)
{
int i=0;
while(!(temp[n]>'a' && temp[n]<'z' || temp[n]>'A' && temp[n]<'Z')) //排除空格
n++;
while(temp[n]>='a' && temp[n]<='z' || temp[n]>='A' && temp[n]<='Z' )
x[k][i++]=temp[n++];
if(x[k]) k++;
while(!(temp[n]>'a' && temp[n]<'z' || temp[n]>'A' && temp[n]<'Z')) //排除空格
n++;
{
int n=0,lt,k=0;
char temp[5000];
gets(temp);
lt=strlen(temp);
while(n<lt)
{
int i=0;
while(!(temp[n]>'a' && temp[n]<'z' || temp[n]>'A' && temp[n]<'Z')) //排除空格
n++;
while(temp[n]>='a' && temp[n]<='z' || temp[n]>='A' && temp[n]<='Z' )
x[k][i++]=temp[n++];
if(x[k]) k++;
while(!(temp[n]>'a' && temp[n]<'z' || temp[n]>'A' && temp[n]<'Z')) //排除空格
n++;
for(int i=0;i<k;i++) //输出
cout<<x[i]<<endl;
}
cout<<x[i]<<endl;
}