mmc的英语作文

题目链接:http://henummc.top/problem.php?cid=1001&pid=2

#include<bits/stdc++.h>
using namespace std;
string s="I say to you today, my friends.And so even though we face the difficulties of today and tomorrow, I still have a dream. It is a dream deeply rooted in the American dream.I have a dream that one day this nation will rise up and live out the true meaning of its creed: We hold these truths to be self-evident, that all men are created equal.I have a dream that one day on the red hills of Georgia, the sons of former slaves and the sons of former slave owners will be able to sit down together at the table of brotherhood.I have a dream that one day even the state of Mississippi, a state sweltering with the heat of injustice, sweltering with the heat of oppression, will be transformed into an oasis of freedom and justice.I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin but by the content of their character.I have a dream today!I have a dream that one day, down in Alabama, with its vicious racists, with its governor having his lips dripping with the words of interposition and nullification -- one day right there in Alabama little black boys and black girls will be able to join hands with little white boys and white girls as sisters and brothers.I have a dream today!";
string ss[5000];
int l=0;
void init(){
    string x="";
  
    for(int i=0;i<s.length();i++){
        if(isalpha(s[i])){
            x+=s[i];
        }else{
            ss[l++]=x;
            x="";
            ss[l++]=s[i];
        }
    }
  
}
void f1(){
    string a1,a2;
    cin>>a1>>a2;
    for(int i=0;i<l;i++){
        if(ss[i]==a1) ss[i]=a2;
    }
}
void f2(){
    string a1;
    cin>>a1;
    for(int i=0;i<l;i++){
        if(ss[i]==a1) {
            cout<<i+1<<endl;
            return;
        }
    }
    cout<<0<<endl;
}
void f3(){
    string a1;
    cin>>a1;
    for(int i=l-1;i>=0;i--){
        if(ss[i]==a1) {
            cout<<i+1<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}
void f4(){
    for(int i=0;i<l;i++) cout<<ss[i];
    cout<<endl;
}
int main(){
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    int n;
    init();
    cin>>n;
    int x;
    while(n--){
        cin>>x;
        if(x==1) f1();
        else if(x==2) f2();
        else if(x==3) f3();
        else f4();
    }
  
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值