期望得分:100+100+20=220

实际得分:100+100+20=220

 

2017北京国庆刷题Day6 morning

模拟栈

#include<cstdio>
#include<cstring>
using namespace std;
#define N 10002
char s[N],st[N];
int top;
int main()
{
    freopen("kakutani.in","r",stdin);
    freopen("kakutani.out","w",stdout);
    int n,len,lt;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%s",s);
        len=strlen(s);
        top=0;
        for(int i=0;i<len;i++)
            if(s[i]=='4' || s[i]=='7') continue;
            else if(s[i]!='3') st[++top]=s[i];
            else 
            {
                if(st[top]=='1') top--; 
                else st[++top]='3';
            }
        if(top) for(int i=1;i<=top;i++) putchar(st[i]);
        else putchar('0');
        printf("\n");
    }
}
View Code

相关文章:

  • 2021-10-12
  • 2022-02-04
  • 2021-07-14
  • 2021-12-11
  • 2022-02-08
  • 2021-07-30
  • 2021-08-19
猜你喜欢
  • 2021-11-13
  • 2021-07-30
  • 2021-10-25
  • 2021-12-02
  • 2022-02-13
  • 2021-10-29
  • 2022-02-11
相关资源
相似解决方案