Linux Under-Beat script and random number generator

Source: Internet
Author: User
Tags generator rand

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

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.