CCF 201703-3 Markdown

http://118.190.20.162/view.page?gpid=T55
按题意写呗,把区和行的转换分开

#include<iostream>
#include<string>
using namespace std;
string AA(string str)
{
    string x;
    int f = 0;
    int le = str.size();
    for (int i = 0; i < le; ) {
        if (str[i] == '_') {
            if (f) { x+="</em>"; f = 0; }
            else { x+="<em>"; f = 1; }
            ++i; continue;
        }
        if (str[i] == '[') {
            int j = i ;
            while (str[j++] != ']');
            j--;
            int k = j + 1;
            while (str[k++] != ')');
            k--;
            x += "<a href=\""+AA(string(str,j+2,k-j-2))
                +"\">"+AA(string(str, i + 1, j - i-1))+"</a>";
            i = k + 1; continue;
        }
        x += str[i++];
    }
    return x;
}
int main()
{
    cin.clear();
    string s[200];
    int len = 0;
    int flag = 0;
    while (getline(cin, s[len++]));
    for (int i = 0; i <= len; )
    {
        if (s[i][0] == '#') {
            int j = 0;
            while (s[i][++j] == '#');
            int k = j - 1;
            while (s[i][++k] == ' ');
            cout << "<h" << j << ">" << AA(string(s[i], k, 100)) << "</h" << j << ">" << endl;
            ++i; continue;
        }
        if (s[i][0] == '*') {

            int j = 0;
            if (flag != 2) cout << "<ul>" << endl;
            flag = 2;
            while (s[i][++j] == ' ');
            cout << "<li>" << AA(string(s[i], j, 100)) << "</li>" << endl;
            ++i; continue;
        }
        if (s[i] == "") {
            if (flag == 2) cout << "</ul>" << endl;
            flag = 0;
            ++i; continue;
        }
        if (flag == 0) cout << "<p>";
        flag = 1;
        cout << AA(s[i]);
        if (s[++i] == "") { cout << "</p>" << endl; }
        else cout << endl;
    }

    return 0;

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
以下是第一段代码的解答: ccf201703-2是一个关于学生移位操作的问题。代码中使用了结构体来存储学生的编号和他在队伍中的位置,并通过重载运算符来对学生元素按照位置进行排序。首先,输入学生的数量n,并初始化一个vector来存储学生的信息。然后,根据学生的数量循环输入每个学生的编号和初始位置,并将其添加到vector中。接下来,输入移位操作的次数m,并循环输入每个移位操作的目标学生编号和移动的位置。根据目标学生编号,找到对应的学生在vector中的位置,并将其位置更新为目标位置。如果目标位置大于0,则将其前面的学生位置都减1;如果目标位置小于0,则将其后面的学生位置都加1。最后,对vector进行排序,并输出排序后的学生编号。 请注意,这段代码中使用了C++的一些语法和库函数,需要在编译时包含相关的头文件。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [CCF:201703-2 学生排队](https://blog.csdn.net/weixin_42729072/article/details/105435070)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [第十次ccf 学生排队](https://blog.csdn.net/xiaoli_nu/article/details/65468043)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [CCF-CSP 201703-2学生排队 一维数组满分题解](https://blog.csdn.net/m0_53641110/article/details/121446439)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值