Data Generation Python Script

Source: Internet
Author: User

Here is the project structure:

--Data storage folder --main. CPP the correct data for the topic -proddata.py  generates the input-output data script --test.  CPP     test code --testdata.py  test code is correct script

proddata.py

#-*-coding:utf-8-*-" "@auther: Starry@file:proddata.py@time:2018/1/17 15:47" "ImportRandomImportosdatasize= 10" "one set of data per data" " forIinchRange (datasize):Print('The %dth set of test data is being produced.'%i) with open ('./data/test'+str (i) +'. in','W', encoding='Utf-8') as F:n= Random.randint (1, 100000) M= Random.randint (1, 100000) F.write (str (N)+' '+str (M) +'\ n')         forJinchRange (M): a= Random.randint (1,10000) b= Random.randint (1,10000) C= Random.randint (1,200) F.write (str (a)+' '+str (b) +' '+str (c) +'\ n') with open ('./data/test'+str (i) +'. out','W', encoding='Utf-8') as F:PassOs.system ('g++-std=c++11 Main.cpp-o main') Os.system ('Main < Data\\test'+str (i) +'. In >> data\\test'+str (i) +'. out')" "multiple sets of data 0 end" "#For i in range (datasize):#print (' The%dth set of test data is being produced. ' %i)#with open ('./data/test ' +str (i) + '. ', ' W ', encoding= ' utf-8 ') as F:#While True:#N = Random.randint ( -70,1000)#if N <= 0:#f.write (str (0) + ' \ n ')# Break#f.write (str (N) + ' \ n ')#For J in Range (N):#a = Random.randint (1,50)#F.write (str (a) + ")#f.write (' \ n ')#M = Random.randint (0,1000)#f.write (str (M) + ' \ n ')#with open ('./data/test ' +str (i) + '. Out ', ' W ', encoding= ' utf-8 ') as F:#Pass#Os.system (' g++-std=c++11 main.cpp-o main ')#Os.system (' main < data\\test ' +str (i) + '. ' >> data\\test ' +str (i) + '. Out ')" "multiple sets of data" "#For i in range (datasize):#print (' The%dth set of test data is being produced. '% i)#with open ('./data/test ' +str (i) + '. ', ' W ', encoding= ' utf-8 ') as F:#For J in Range (Random.randint (1,20)):#N = Random.randint (1, +)#M = Random.randint (1, +)#K = Random.randint (1, +)#S = Random.randint (1, +)#f.write (str (N) + ' +str (M) + ' +str (K) + ' +str (S) + ' \ n ')#For K in range (k):#a = Random.randint (1,20)#B = Random.randint (1,20)#F.write (str (a) + ' +str (b) + ' \ n ')#with open ('./data/test ' +str (i) + '. Out ', ' W ', encoding= ' utf-8 ') as F:#Pass#Os.system (' g++-std=c++11 main.cpp-o main ')#Os.system (' main < data\\test ' +str (i) + '. ' >> data\\test ' +str (i) + '. Out ')

testdata.py

#-*-coding:utf-8-*-" "@auther: Starry@file:testdata.py@time:2018/1/17 15:46" "Importosdatasize= 10Os.system ('g++ test.cpp-o Test') WA=False forIinchRange (datasize):Print('The %dth set of data is being tested.'%i) Os.system ('Test < Data\\test'+str (i) +'. in > Te.out') Flag= Os.system ('FC Data\\test'+str (i) +'. Out te.out > Nul')    ifFlag! =0:Print('wrong answer on test'+str (i) +'. In!!!') WA=Trueif  notWA:Print("Accepted!!!")

Data Generation Python Script

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.