"Template" to Pat Program

Source: Internet
Author: User

Objective

Exams have been tested dozens of sets, has not been to shoot, greedy problem or can not write out, or manually create a few data shot.

Today the mood is not very good, does not want to write the question, is everywhere to pick up I thought slightly looks a bit also good back a bit of pat.

The package is A+B code and data generation code, you can try it. Random data generation compared to water, I haven't studied it yet, but I can use it.

I almost knocked 5 times before I memorized this pair of shots ...

Code-to-PAT program

Library functions cannot be saved

#include <cstdio>#include<cstdlib>#include<ctime>intMain () {Longs,t;  while(1) {System ("CLS");  Do{System ("Data > Try.in");//Data Generation Programs=clock (); System ("a < try.in > Try1.out");//Positive Solutiont=clock (); System ("B < try.in > Try2.out");//violence            if(System ("FC Try1.out try2.out > Nul")) Break; Elseprintf"AC time:%ldms\n", Ts); } while(1); printf ("WA time:%ldms\n", Ts); System ("FC Try1.out Try2.out"); System ("Pause > Nul"); }}
Positive solution
#include <iostream>usingnamespace  std; int Main () {    int A, b;    CIN>>a>>b;    cout<<a+b<<Endl;     return 0 ;}
Violence
#include <iostream>usingnamespace  std; int Main () {    int A, b;    CIN>>a>>b;      while (b--) a++;    cout<<a<<Endl;     return 0 ;}
Random Data generation
#include <iostream>#include<ctime>#include<cstdlib>using  namespace  std; int Main () {    srand ((unsigned) time (0));     int b;    A=rand ();    b=rand ();    cout<<a<<'<<b<<Endl;     return 0 ;}
Operating result AC effect

WA effect

"Template" to Pat Program

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.