Hello,
I have been using online judge for a couple of weeks.
My system is running on an ubuntu 8.04, with moodle 1.9
I use libsandbox, not the
ideone.com.
This program below runs fine when I run it manually (When I compile
with gcc -Wall main.c -o main.out -lm, and than issue
main.out<input.txt >output.txt).
But when I give a particular input, the online judge system can not
produce correct output. I absolutely positively am sure that I
uploaded right input and output files and main.c. In fact, I wrote a
shell script that automatically compiles the main.c, calles the
executable on input files to get output files, and copies them to
correct moodle directories. Then I manually arrange test cases.
The code divides given money amount using least amount of liras and
kuruses (Turkish currency, just read lira as dollar and kurus as
cent.):
-------------------main.c------------------------
#include <stdio.h>
int main()
{
int inlira,inkurus;
inlira = 0;
inkurus = 0;
scanf("%d.%d",&inlira,&inkurus);
int tl[] = {200,100,50,20,20,5,1};
int kr[] = {50,25,10,5,1};
if (inlira > 9999 || inkurus > 99 )
{
printf("H");
return 0;
}
int i;
for (i=0; i<7; i++)
{
int adet = inlira / tl[i];
inlira -= adet*tl[i];
if (adet) printf("%d %dTL\n",adet,tl[i]);
}
for (i=0; i<5; i++)
{
int adet = inkurus/kr[i];
inkurus -=adet*kr[i];
if (adet) printf("%d %dKR\n",adet,kr[i]);
}
return 0;
}
--------------input.txt-----------------
989888
When given 989888, the output.txt should be just 'H', but the
onlinejudge system in moodle says the output.txt is
4949 200TL
1 50TL
1 20TL
3 5TL
3 1TL
I tried to debug by running under sand manually like ...sand ./
main.out <input.txt >output.txt
but nothing happens.
Thanks in advance...