码迷,mamicode.com
首页 > 其他好文 > 详细

18 D - This cheeseburger you don't need(URAL1993)

时间:2016-05-19 21:01:34      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

题意硬伤,看样例看懂得!实际就是个模拟题,没想到没加括号的不能在中间出现,哔了狗了!

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<stdlib.h>
using namespace std;


char s[110];
char ans[3][110];
char chu[110];
char dou[3];
int main()
{
    int i;
    gets(s);
    int l=strlen(s);
    memset(chu,0,sizeof(chu));
    int k=0,xl=0;
    for(i=0;i<l;i++)
    {
        if(s[i]=={)
        {
            int j=0;
            i++;
            while(i!=l&&s[i]!=})
            {
                ans[0][j++]=s[i];
                i++;
            }
            ans[0][j++]= ;
            ans[0][j]=\0;
        }
        else if(s[i]==()
        {
            int j=0;
            i++;
            while(i!=l&&s[i]!=))
            {
                ans[1][j++]=s[i];
                i++;
            }
            ans[1][j++]= ;
            ans[1][j]=\0;
        }
        else if(s[i]==[)
        {
            int j=0;
            i++;
            while(i!=l&&s[i]!=])
            {
                ans[2][j++]=s[i];
                i++;
            }
            ans[2][j]=\0;
        }
        else if(s[i]==,)
        {
                dou[0]=,;
                dou[1]= ;

                strcat(chu,ans[0]);
                strcat(chu,ans[1]);
                strcat(chu,ans[2]);
                strcat(chu,dou);
                i++;
                xl=strlen(chu);
                int k=xl;
                while(i!=l&&s[i]!=[&&s[i]!=(&&s[i]!={)
                {

                    chu[k++]=s[i];
                    i++;
                }
                i--;
                memset(ans,0,sizeof(ans));
        }

    }
    strcat(chu,ans[0]);
    strcat(chu,ans[1]);
    strcat(chu,ans[2]);

    xl=strlen(chu);
    for(i=0;i<xl;i++)
    {
        if(i==0)
        {
            if(chu[i]<=z&&chu[i]>=a)
                chu[i]=chu[i]-32;
        }
        else
        {
            if(chu[i]<=Z&&chu[i]>=A)
                chu[i]=chu[i]+32;
        }
    }
    printf("%s\n",chu);
    return 0;
}

 

18 D - This cheeseburger you don't need(URAL1993)

标签:

原文地址:http://www.cnblogs.com/wuxinganchu/p/5509771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!