多文件输入对拍脚本

#!/bin/sh
# put the code and data in the same folder
in="in"      #data's inputs file suffix
out="out"     #Analogy above 
cpp="a.cpp"     # the CPP of yours.BTW you should comment the freopen
prog="test"     #compilation's product
myoutput="myans" #program's output 
g++ -O2 $cpp -o  $prog #compile command

for file in ./*
do
    if test -f $file
    then
    name=${file##*/}
    suff=${name#*.}
    pre=${name%%.*}
    #echo $name $pre $suff
    #echo $file
    if test $suff = $in
    then
        infile=$name
        outfile=$pre.$out
        ./$prog <$infile >$myoutput
        if diff $myoutput $outfile
        then
            echo $infile AC
        else
            echo $infile WA
        fi
        
    fi
    fi
done

猜你喜欢

转载自www.cnblogs.com/polya/p/9711034.html