Advertisement
tien_noob

Generate test + compare code C++ (Use for offline)

Jun 12th, 2021 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. //Make CSP great again
  2. #include <bits/stdc++.h>
  3. #define TASK "TESTCODE"
  4. using namespace std;
  5. const string NAME = "TESTCODE";
  6. mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
  7. long long Rand(long long l, long long r)
  8. {
  9.     return l + rd() * 1LL * rd() % (r - l + 1);
  10. }
  11. void Gentest()
  12. {
  13.    cout << Rand(1, 1e12);
  14. }
  15. void OutputTest()
  16. {
  17.  
  18. }
  19. int main()
  20. {
  21.    //ios_base::sync_with_stdio(false);
  22.    //cin.tie(nullptr);
  23.    int t; cin >> t;
  24.    for (int i = 1; i <= t; ++ i)
  25.    {
  26.        ofstream inp((NAME + ".INP").c_str());
  27.        Gentest();
  28.        inp.close();
  29.        system((NAME + ".exe").c_str());
  30.        system((NAME + "_trau").c_str());
  31.        if (system(("fc " + NAME + ".OUT " + NAME + ".ANS").c_str()) != 0)
  32.        {
  33.            cout << "TEST " << i << ": WRONG";
  34.            OutputTest();
  35.            return 0;
  36.        }
  37.        cout << "TEST " << i << ": CORRECT" << '\n';
  38.    }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement