• 对拍系列 v1.0


    效果图:在这里插入图片描述

    代码实现:

    #include 
    #include 
    #include 
    
    using namespace std;
    
    char _1[10], _2[10];
    
    int main()
    {
    //  freopen ("xx.out", "w", stdout);
      srand(time(0));
      HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
      system("g++ your-code.cpp -o a.exe -std=c++14 -g");
      system("g++ answer.cpp -o b.exe -std=c++14 -g");
      system("g++ maker.cpp -o c.exe -std=c++14 -g");
      int score = 0;
      const int tle = 200;
      for (int ca = 1; ca <= 25; ca++)
      {
    //    system("color 0f");
        SetConsoleTextAttribute(hConsole, 7);
    //    fprintf (stderr, "Running On Test %d: \n", ca);
        srand(time(0));
        system("c.exe");
    //    Sleep(666);
        errno = 0;
        clock_t st = clock();
        system("a.exe < sample.in > your-code.out");
        clock_t ed = clock();
        if (errno)
        {
          SetConsoleTextAttribute(hConsole, 13);
          fprintf (stderr, "R Run Time Error On Test #%d\n", ca);
        }
        double ut = ed - st;
        if (ut > tle) {
          SetConsoleTextAttribute(hConsole, 9);
          fprintf (stderr, "T Time Limit Exceed On Test #%d\n", ca);
        }
        system("b.exe < samp.in > answer.out");
        if (system("fc your-code.out answer.out"))
        {
    //      system("color 07");
          ae:;
          SetConsoleTextAttribute(hConsole, 4);
          fprintf (stderr, "× Wrong Answer On Test #%d, your answer is %s, expect %s\n", ca, _1, _2);
        }
        else
        {
          af:;
    //      system("color 0a");
          SetConsoleTextAttribute(hConsole, 10);
          fprintf (stderr, "√ Accepted On Test #%d\n", ca);
          score += 4;
        }
    //    Sleep(1000);
      }
      fprintf (stderr, "Score = %d", score);
      return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61

    下一期预告:判断MLE错误。

    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数
    凑字数凑字数凑字数凑字数

  • 相关阅读:
    c 语言基础:L1-047 装睡
    Go语言:基础练习--删除数组指定元素
    科普向丨语音芯片烧录工艺的要求
    cobol数据类型
    数组的对象
    Spring Data Elasticsearch介绍(七)
    48. 从零开始学springboot: 接入RocketMQ
    docker启动链接sqlservr的镜像时报SSl错误
    Go分布式缓存 HTTP 服务端(day3)
    为修复各种问题,iOS 17.1应运而生,那么它到底解决什么问题或带来什么功能呢
  • 原文地址:https://blog.csdn.net/lxylluvio/article/details/126609626