libsandbox

64 views
Skip to first unread message

comparim

unread,
Nov 21, 2010, 2:02:31 PM11/21/10
to Sunner Moodle Plugins
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...

Zhigang Sun

unread,
Nov 21, 2010, 7:37:13 PM11/21/10
to sunner-moodle-plugins
Thank you for the long details. Very helpful!


You mentioned:
" the output.txt is
4949 200TL
1 50TL
1 20TL
3 5TL
3 1TL"
But oj can't generate any output files. How can you get the file?


--
You received this message because you are subscribed to the Google Groups "Sunner Moodle Plugins" group.
To post to this group, send email to sunner-moo...@googlegroups.com.
To unsubscribe from this group, send email to sunner-moodle-pl...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sunner-moodle-plugins?hl=en.




--
哈尔滨工业大学(Harbin Institute of Technology)
孙志岗(Sun Zhigang)
http://sunner.cn
Reply all
Reply to author
Forward
0 new messages