Table of Contents:
Return to the Top of Page, First Page, Novice Problem Set, or Veteran Problem Set.
Borland Turbo Pascal v1.5 for Windows
NOTES | File Naming Conventions | To Make It Work | Example Program | Judges Information
NOTES:
Filenaming Conventions:
- All source submissions should have a file naming convention of p[n|v]<num>.pas where:
[n|v] refers to either novice or veteran
<num> refers to the problem number
For example, if you are a novice team working on problem 3, your filename would be: pn3.pas
- If you are planning to do file I/O, you must name your input file test.in and your output file must be test.out.
To Make It Work:
Example Program:
program Welcome;
uses WinCRT;
var
name: string;
begin
Assign(Input,'pb3.in'); Reset(Input);
Assign(Output,'pb3.out'); Rewrite(Output);
Readln(name);
Writeln('Welcome to Turbo Pascal for Windows, ',name);
Close(Output);
end.
Items in cyan are the needed additions for file I/O using standard I/O commands.
Judges Information:
- Delete C:\TEMP\test.*
- Open Borland Turbo Pascal and create a TEST.PAS file
- Copy the student's source from their submitted file and paste it into the TEST.PAS
- Copy the Judge Data for the particular problem from J:\ to C:\TEMP\test.in
- Look for the I AM USING FILE I/O comment. If it is present, skip this section:
- Make sure there is a uses WinCRT; section
- Add the following two lines just after the begin of the main program (if they aren't already there):
Assign(Input,'C:\TEMP\test.in'); Reset(Input);
Assign(Output,'C:\TEMP\test.out'); Rewrite(Output);
- Add the following line just before the end. of the main program:
- Select Compile | Build
- Select Run | Run
- Use NotePad or WordPad or Pascal to view the output file C:\TEMP\test.out
to determine if the solution is correct
Return to the Top of Page, First Page, Novice Problem Set, or Veteran Problem Set.
Borland Turbo C++ v4.5
NOTES | File Naming Conventions | To Make It Work | Example Program | Judges Information
NOTES:
- Only use standard I/O routines that read from STDIN and write to STDOUT i.e. scanf and printf.
- If you'd like to do file based I/O instead of keyboard input and screen output, see the To Make It Work section below.
File Naming Conventions:
To Make It Work:
- Add the following code at the top of your source:
#include <sys\stat.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#define STDOUT 1
#define STDIN 0
int nul, oldstdout;
int nulin, oldstdin;
void reDIRect()
{
/* create a file */
nul = open("test.out", O_CREAT | O_RDWR,
S_IREAD | S_IWRITE);
nulin = open("test.in", O_RDONLY);
/* create a duplicate handle for standard output */
oldstdout = dup(STDOUT);
oldstdin = dup(STDIN);
/*
redirect standard output to DUMMY.FIL
by duplicating the file handle onto
the file handle for standard output.
*/
dup2(nul, STDOUT);
dup2(nulin, STDIN);
/* close the handle for DUMMY.FIL */
close(nul);
close(nulin);
/* will be redirected into DUMMY.FIL */
return;
};
void UNreDIRect ()
{
dup2(oldstdout, STDOUT);
dup2(oldstdin, STDIN);
/* close duplicate handle for STDOUT */
close(oldstdout);
close(oldstdin);
}
- Put the following line as the first line of your main function:
reDIRect();
- Put the following line as the last line of your main (before any returns or exits) function:
UNreDIRect();
Example Program:
#include <sys\stat.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#define STDOUT 1
#define STDIN 0
int nul, oldstdout;
int nulin, oldstdin;
void reDIRect()
{
/* create a file */
nul = open("test.out", O_CREAT | O_RDWR,
S_IREAD | S_IWRITE);
nulin = open("test.in", O_RDONLY);
/* create a duplicate handle for standard output */
oldstdout = dup(STDOUT);
oldstdin = dup(STDIN);
/*
redirect standard output to DUMMY.FIL
by duplicating the file handle onto
the file handle for standard output.
*/
dup2(nul, STDOUT);
dup2(nulin, STDIN);
/* close the handle for DUMMY.FIL */
close(nul);
close(nulin);
/* will be redirected into DUMMY.FIL */
return;
};
void UNreDIRect ()
{
dup2(oldstdout, STDOUT);
dup2(oldstdin, STDIN);
/* close duplicate handle for STDOUT */
close(oldstdout);
close(oldstdin);
}
int main(void)
{
char name[40];
reDIRect();
/* restore original standard output handle */
printf("hello\n");
scanf("%s",&name);
printf("Hello %s\n",name);
UNreDIRect();
return 0;
}
Judges Information:
- Delete C:\TEMP\test.*
- Open Borland Turbo C++
- File | New
- File | SaveAs and save as C:\TEMP\test.cpp
- Copy the student's source into test.cpp
- See if the I AM USING FILE I/O is present. If it is, skip this step. If it is not, add the file I/O code shown in cyan in the Example Program above.
- File | Save
- Select Project | Build all
- Look for a C:\TEMP\test.exe. If it's not there, verify that the cyan code you pasted from the Example Program is correct -- check for duplicated #include <xxxxx>'s. If that all looks O.K., you may reject their program with a CE compile error.
- Copy the Judge Data for the particular problem from J:\ into C:\TEMP\test.in
- Open a Command Prompt and cd C:\TEST
- Run the program by typing test and [return]
- Open Notepad
- File | Open the C:\TEMP\test.out and compare their output with the Official Judges Output from J:\P#[n|v]
Return to the Top of Page, First Page, Novice Problem Set, or Veteran Problem Set.
Microsoft QBasic
NOTES | File Naming Conventions | To Make It Work | Example Program | Judges Information
Return to the Top of Page, First Page, Novice Problem Set, or Veteran Problem Set.
Microsoft Visual Basic v5.0
NOTES | File Naming Conventions | To Make It Work | Example Program | Judges Information
NOTES:
- When you create your project, just select the standard.exe, not a GUI. Use only one form for your application. Submit only your form file (we just need the form source-- not the whole project).
File Naming Conventions:
- All source submissions should have a file naming convention of p[n|v]<num>.frm where:
[n|v] refers to either novice or veteran
<num> refers to the problem number
For example, if you are a novice team working on problem 3, your filename would be: pn3.frm
To Make It Work:
- Make sure to Open a local textfile for your input. We will be using command-line based redirection for testing. Also, you'll need to Open a second stream for local based textfile output. See the Example Program below.
Example Program:
Private Sub Form_Load()
Close #1
Open "c:\temp\a.a" For Input As #1
Dim b As Integer, c As Integer, d, e, f As Integer
Dim aa As Integer, bb As Integer, cc As Integer
b = 1
While b <> 0
Input #1, b
Input #1, c
f = b * c
Open "c:\temp\b" For Append As #2
Print #2, f
Close #2
Wend
Close #1
Unload Me
End Sub
Judges Information:
Return to the Top of Page, First Page, No
vice Problem Set, or Veteran Problem Set.
Microsoft Visual C/C++ v5.0
NOTES | File Naming Conventions | To Make It Work | Example Program | Judges Information
NOTES:
- When creating a new project, make sure you select Win32 Console Application for the project type!
- When creating a new source file, choose C++ Source File and let it append a .cpp to your filename (this works even if you only code in C).
- The only types of files in your project should be C/C++ Header File and/or C++ Source File.
- Name the project and source file according to the File Naming Conventions below.
- Your project should have one .cpp file and may optionally have one matching .h file.
File Naming Conventions:
To Make It Work:
- Under the Build menu, select Rebuild All to compile.
- Under the Build menu, select Execute <filename> to run.
Example Program:
#include <stdio.h>
void main()
{
char name[80];
printf("What's your name? ");
scanf("%s",name);
printf("\nHello World!, %s\n",name);
}
Judges Information:
Steps to Judge
- Delete the old test project (you won't have to do this the first time) from the C:\TEMP\ directory with Windows Explorer
- Make a new Win32 Console Application test project in the C:\TEMP directory.
- Add a new judge C/C++ source file to the project.
- Paste user's source code into the source document.
- Build (it saves the compiled version to disk in the C:\TEMP\TEST\JUDGE\DEBUG directory).
- Switch to a DOS window.
- cd to the C:\TEMP\TEST\JUDGE\DEBUG directory.
- Copy the input datafile from C:\TEMP to this same directory.
- Run the program by: filename.exe < inputfile > outputfile
- Use Notepad to open the outputfile and compare it with the provided Solution Docuentation
Return to the Top of Page, First Page, No
vice Problem Set, or Veteran Problem Set.
The statements and opinions included in these pages are those of the LSU High School Programming Contest Staff only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 1999 LSU High Sc
hool Programming Contest
Return to the LSU High School Programming Contest Homepage