#include <iostream>
#include <string>
using namespace std;
const int MAX = 1000;
string result;
bool acm2(const int& i)
{
if(i>MAX-3)
return false;
if((result[i]=='a'||result[i]=='A')&&(result[i+1]=='c'||result[i+1]=='C')&&(result[i+2]=='m'||result[i+2]=='M'))
return true;
else
return false;
}
bool oj2(const int& i)
{
if(i>MAX-2)
return false;
if((result[i]=='o'||result[i]=='O')&&(result[i+1]=='j'||result[i+1]=='J'))
return true;
else
return false;
}
void print2()
{
int i = 0;
while(i<MAX)
{
if(result[i] == '\n')
{
cout<<' ';
i++;
}
else if(acm2(i))
{
cout<<"ACM/ICPC\n";
i+=3;
}
else if(oj2(i))
{
cout<<"jojer";
i+=2;
}
else
{
cout<<result[i];
i++;
}
}
}
int main()
{
string str;
int count = 0;
int tmp;
while(getline(cin, str))
{
tmp = count;
count+=(str.size()+1);
if(count>MAX)
{
str = str.substr(0, MAX-tmp);
result+=str+"\n";
break;
}
result+=str+"\n";
}
print2();
return 0;
}
------------------------
有部分问题,不能AC,但值得记录
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 1000;
char a[MAX+1];
//#define TEST
bool acm(const int& i)
{
if(i>MAX-3)
return false;
if((a[i]=='a'||a[i]=='A')&&(a[i+1]=='c'||a[i+1]=='C')&&(a[i+2]=='m'||a[i+2]=='M'))
return true;
else
return false;
}
bool oj(const int& i)
{
if(i>MAX-2)
return false;
if((a[i]=='o'||a[i]=='O')&&(a[i+1]=='j'||a[i+1]=='J'))
return true;
else
return false;
}
void print()
{
int i = 0;
while(i<MAX)
{
if(a[i] == '\n')
{
cout<<' ';
i++;
}
else if(acm(i))
{
cout<<"ACM/ICPC\n";
i+=3;
}
else if(oj(i))
{
cout<<"jojer";
i+=2;
}
else
{
cout<<a[i];
i++;
}
}
}
int main()
{
#ifdef TEST
freopen("in.dat", "wb", stdout);
for(int i=0;i<100;i++)
cout<<"acmJacOoj\n";
#endif
#ifndef TEST
freopen("in.dat", "r", stdin);
scanf("%[]", a);
print();
system("pause");
#endif
return 0;
}