zoukankan      html  css  js  c++  java
  • hdu 1073 字符串处理

    题意:给一系列的输出和标准答案,比较二者是AC,PE或WA

    字符串处理还是比较薄弱,目前没什么时间搞字符串专题,所以遇到一题就努力搞懂

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<algorithm>
     4 #include<cstring>
     5 #include<cmath>
     6 #include<queue>
     7 #include<map>
     8 using namespace std;
     9 #define MOD 1000000007
    10 const double eps=1e-5;
    11 #define cl(a) memset(a,0,sizeof(a))
    12 #define ts printf("*****
    ");
    13 const int MAXN=6005;
    14 char a1[MAXN],a2[MAXN],b1[MAXN],b2[MAXN];
    15 int n,m,tt;
    16 char temp[MAXN];
    17 void in(char a[],char b[])
    18 {
    19     gets(temp);
    20     while(strcmp(temp,"START")!=0)    gets(temp);   //START之前的都去掉
    21     while(gets(temp))
    22     {
    23         if(strcmp(temp,"END")==0)   break;
    24         if(strlen(temp)!=0) strcat(a,temp); //读入的不为换行符
    25         strcat(a,"
    ");
    26     }
    27     int t=0;
    28     for(int i=0;i<strlen(a);i++)
    29     {
    30         if(a[i]!=' '&&a[i]!='
    '&&a[i]!='	')   //	要加,因为题目中有要求,汗
    31         {
    32             b[t++]=a[i];
    33         }
    34     }
    35     b[t]='';  //注意这个一定要加,否则没办法比较
    36 }
    37 int main()
    38 {
    39     int i,j,k;
    40     #ifndef ONLINE_JUDGE
    41     freopen("1.in","r",stdin);
    42     #endif
    43     scanf("%d",&tt);
    44     while(tt--)
    45     {
    46         a1[0]='';
    47         a2[0]='';
    48         in(a1,b1);
    49         in(a2,b2);
    50         if(strcmp(a1,a2)==0)    printf("Accepted
    ");       //未被删除格式前都相同,说明完全相同
    51         else if(strcmp(b1,b2)==0)   printf("Presentation Error
    ");
    52         else printf("Wrong Answer
    ");
    53     }
    54 }
  • 相关阅读:
    我败在了盲目和没有计划
    跟我一起学.NetCore目录
    跟我一起学.NetCore之依赖注入作用域和对象释放
    跟我一起学.NetCore之Asp.NetCore启动流程浅析
    std::unordered_map
    Android apps for “armeabi-v7a” and “x86” architecture: SoC vs. Processor vs. ABI
    android studio 配置相关问题
    shell script
    vscode配置
    linux常用命令笔记
  • 原文地址:https://www.cnblogs.com/cnblogs321114287/p/4436778.html
Copyright © 2011-2022 走看看