NC16644 [NOIP2007]字符串的展开


题目

  • 原题地址:字符串的展开
  • 题目编号:NC16644
  • 题目类型:模拟
  • 时间限制:C/C++ 1秒,其他语言2秒
  • 空间限制:C/C++ 262144K,其他语言524288K

1.题目大意

  • 替换字符串省略的部分,如d-h替换成defgh,同时添加了替换规则:
  1. 大小写
  2. 重复次数
  3. 正逆序

2.题目分析

  • 就模拟,但是需要注意几种情况:
  • a----
  • 2-abc-2

3.题目代码

#include 

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    string str0;
    cin >> str0;
    string str1 = "";
    int m;
    for(m = 0; str0[m] != '\0'; m++)
    {
        if(str0[m] == '-') 
            cout << '-';
        else 
            break;
    }
    for(int i=m;i=str0[i+2]-'0'||(isdigit(str0[i])&&isalpha(str0[i+2])))
            {
                //str1 = str1 + str0[i] + str0[i+1];
                str1 += '-';
                i++;
            }
            else if(str0[i]-'0'==str0[i+2]-'0'-1)
            {
                //str1 = str1 + str0[i];
                i++;
                continue;
            }
            else if((isalpha(str0[i]) && isalpha(str0[i+2]))||(isdigit(str0[i]) && isdigit(str0[i+2])))
            {
                string tmp="";
                if(a==1)
                {
                    char ch;
                    for(int j=1;j='a')
                    {
                        char ch;
                        for(int j=1;j