CSP模板生成系统

开门见山,直接放一百分代码:

c 复制代码
#include<iostream>
#include<algorithm>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
const int N = 2e4 + 10;
string a[1010];
unordered_map<string , string> mp;

void check(string &s)
{
    int len = s.size();
    string res = "";
    string z;
    for(int i = 0 ; i < len ; i++)
    {
        if(s[i] == '{' && s[i + 1] == '{')
        {
            int j = i + 3;
            string k="";
            while(s[j] != ' ')
            {
                k += s[j];
                j++;
            }
            if(mp.count(k) == 0){
                i = j + 2;
                continue;
            }
            z = mp[k];
            i = j + 2;
            res += z;
            continue;
        }
        res += s[i];
    }
    s = res;
}

int main()
{
    int m , n;
    cin >> m >> n;
    getchar();
    for(int i = 1 ; i <= m ; i++)
    {
        getline(cin , a[i]);
    }
    for(int i = 1 ; i <= n ; i++){
        string k;
        string z;
        cin >> k;
        getline(cin , z);
        string zz="";
        for(int j = 2 ; j < z.size()-1 ; j++)
            zz += z[j];
        mp[k] = zz; 
    }
    for(int i = 1 ; i <= m ; i++)
    {
        check(a[i]);
        cout << a[i] << endl;
    }
    return 0;
}
相关推荐
future141211 分钟前
C#学习日记
开发语言·学习·c#
码农编程录17 分钟前
【c/c++3】类和对象,vector容器,类继承和多态,systemd,std&boost
c++
king_harry27 分钟前
Java程序-OceanBase Connector/J 示例
开发语言
martian6651 小时前
支持向量机(SVM)深度解析:从数学根基到工程实践
算法·机器学习·支持向量机
孟大本事要学习1 小时前
算法19天|回溯算法:理论基础、组合、组合总和Ⅲ、电话号码的字母组合
算法
傻啦嘿哟1 小时前
Python 办公实战:用 python-docx 自动生成 Word 文档
开发语言·c#
翻滚吧键盘1 小时前
js代码09
开发语言·javascript·ecmascript
q567315231 小时前
R语言初学者爬虫简单模板
开发语言·爬虫·r语言·iphone
??tobenewyorker2 小时前
力扣打卡第二十一天 中后遍历+中前遍历 构造二叉树
数据结构·c++·算法·leetcode
贾全2 小时前
第十章:HIL-SERL 真实机器人训练实战
人工智能·深度学习·算法·机器学习·机器人