to Pat Script
Create a new document CHECK.SH as the Pat script.
#!/bin/Bash while(true) Do#死循环./data >1.inch#运行数据生成器, output the data to 1.inch ./STD <1.inch>out1 #std是标准 (violence) program./now <1.inch>Out2 #now是现在要被测的程序ifDiff-w OUT1 Out2; Then #比较,-W is to ignore the end of line echo AC #如果一样就输出ACElseecho WA cat out1 Out2 #不然就输出WA and shows a different place Breakfi #结束ifsleep1#如果使用srand (), the random number is the second level, with sleep 1 Let it delay one second, not the same data in a second run many times done #结束循环
View Code
In the directory where the command line data.sh is located, enter the./check.sh to run.
If the display permissions are not sufficient, enter: chmod 777./check.sh. Where 777 represents open access to all users or whatever.
Random number generator
#include <cstdio>#include<cstdlib>#include<ctime>using namespacestd;intMain () {srand (unsignedint) Time (NULL)); for(intI=1; i<=2; i++) {printf ("%d",(int) (rand ()%10000)); } return 0;}//if you compile with std=c++11, you can use the Stdlib and time header files instead of random .
second-level random number
#include <cstdio>#include<random>using namespacestd;intMain () {Random_device seed; mt19937 RAND (Seed ()); for(intI=1; i<=2; i++) printf ("%d",(int) (RAND ()%10000)); return 0;}//must be compiled with std=c++11
true random number under Linux (recommended)
The example is to generate two random numbers.
Linux Under-Beat script and random number generator