• HDU 1073 Online Judge


    字符串比较,3种结果:AC,PE,WA;为了好处理中间的数据让所有输入的字符串连起来并且让两种输入的行数相同,(除却空行)

    一个输入函数,一个处理函数

    附代码

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 using namespace std;
     5 const int N=5005;
     6 void input(char s[]) {
     7     s[0]='';
     8     char tmp[N];
     9     getchar();
    10     gets(tmp);
    11     while(gets(tmp)) {
    12         if(strcmp(tmp,"END")==0) {
    13             break;
    14         } else {
    15              if(strlen(tmp))//tmp
    16                 strcat(s,tmp);
    17             strcat(s,"
    ");
    18         }
    19     }
    20 
    21     //puts(s);
    22 }
    23 int deal(char a[],char b[]){
    24     if(strcmp(a,b)==0)
    25         return 1;
    26     int j=0;
    27     for(int i=0;i<strlen(a);i++){
    28         if(a[i]!=' '&&a[i]!='	'&&a[i]!='
    '){
    29             a[j++]=a[i];
    30         }
    31     }
    32     a[j]='';
    33     j=0;
    34     for(int i=0;i<strlen(b);i++){
    35         if(b[i]!=' '&&b[i]!='	'&&b[i]!='
    '){
    36             b[j++]=b[i];
    37         }
    38     }
    39     b[j]='';
    40 //    printf("deal a =");
    41 //    puts(a);
    42 //    printf("deal b =");
    43 //    puts(b);
    44     if(strcmp(a,b)==0)
    45         return 2;
    46     return 0;
    47 }
    48 int main() {
    49 
    50     //freopen("C:\CODE\in.txt", "r", stdin);
    51     //freopen("C:\CODE\out.txt","w",stdout);
    52     int T,n,flg;
    53     char a[N],b[N];
    54     scanf("%d",&T);
    55     while(T--) {
    56         scanf("%d",&n);
    57         input(a);
    58         input(b);
    59         flg=0;
    60         flg=deal(a,b);
    61 
    62         if(flg==1) {
    63             printf("Accepted
    ");
    64         } else if(flg==2) {
    65             printf("Presentation Error
    ");
    66         } else {
    67             printf("Wrong Answer
    ");
    68         }
    69     }
    70 
    71     fclose(stdin);
    72     return 0;
    73 }
    ---------------- 人们生成的最美好的岁月其实就是最痛苦的时候,只是事后回忆起来的时候才那么幸福。
  • 相关阅读:
    mybatis SQL 根据in条件语句排序
    Redis面试总结
    数据库优化之分库分表
    jdk1.6 Synchronized 优化总结
    CounDownLatch、CyclicBarrier、Semaphore
    java锁总结
    Redis 与 MySQL 双写一致性如何保证
    dubbo总结
    一、全国大学生电子设计竞赛测控(无人机)方向___基础篇
    编解码KL变换详解和哥伦布k阶编解码
  • 原文地址:https://www.cnblogs.com/livelihao/p/5164747.html
Copyright © 2020-2023  润新知