PC2 version 7

BETA Judging Scripts Documentation


Introduction

This page includes the following:

How arguments are passed

The script file has 3 arguments, in order:

mainfile.ext main file name (with extension, ie. hello.java)
mainfile main file name (NO extension, ie. hello)
short_lang_name short lang name (ie java)

It is almost a certainty there will be a fourth argument, short problem name or letter

prob_number problem number (ie 1)

Sample Judge Script

Note: the short languages need to be named: java, cpp, and pascal respectively



Click here to download v7judge.bat


Sample Script - C under Unix

Note: pc2 v7 may not support Unix until a later version

rem hello.c hello c
cc -o $2 $1
$2


Sample data file for sum of integers problem

25
50
-25
0

Sample C program - hello world

#include <stdio.h>

main()
{
printf("hello world \n");
}

Sample C program - sum positive integers (use sum.dat)

#include <stdio.h>
main ()
{
FILE *fp = fopen ("sum.dat","r");
int sum = 0;
int i;

if (fp)
{
while (1==fscanf(fp, "%d", &i))
{
sum += i > 0 ? i : 0;
}
fclose (fp);
printf("The sum of the positive integers is %d \n",sum);
}
else
printf("Could not read from file sum.dat \n");
}


Sample Turbo Pascal - hello world

begin
writeln('hello world ');
end.

Sample Pascal - sum of positive integers

var
tf : text;
i : integer;
sum : integer;

begin
assign (tf,'sum.dat');
{$i-} reset (tf); {$i+}
if ioresult <> 0 then
writeln('could not open file sum.dat ')
else
begin
sum := 0;
while not eof (tf) do
begin
readln(tf,i);
if (i > 0) then
sum := sum + i;
end;
writeln('The sum of the positive integers is ',sum);
end;
end.


Sample C++ - hello world

#include <iostream.h>

main()
{
	cout << "hello world\n";
}


Sample java - hello world

// Hello World Program
// pc2@ecs.csus.edu 

public class hello {
    public static void main(String[] args) 
    {
	System.out.println("Hello World.");
    }
}


Revised: Tue Oct 19 21:53:52 PDT 1999