#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main()
{
ifstream infile("带切文本.txt");
if (!infile)
{
cerr<<"error:can not open the file"<<endl;
exit(1);
}
string line;
int flag;
ofstream outfile("result.txt");
while (getline(infile,line))
{
line.erase(0,line.find_first_not_of(' '));
line.erase(0,line.find_first_not_of(' '));
line.erase(line.find_last_not_of(' ')+1);
if (!line.empty())
{
flag=0;
int k=0;
for (int i=0;i<line.size();i++)
{
if(line[i]>=0 && line[i]<128)
{
outfile<<line[i];
flag=1;
}
else
{
k++;
if(flag==1)
outfile<<" ";
if (k%2 != 0)
{
outfile<<line[i];
}
else
{
outfile<<line[i]<<" ";
k=0;
}
flag=0;
}
}
outfile<<endl;
}
}
infile.close();
outfile.close();
}