2531

#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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值