Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2005.12.11;
Скачать: [xml.tar.bz2];

Вниз

Почему не работает проверялка?   Найти похожие ветки 

 
IAMDANIL ©   (2005-11-26 13:43) [0]

Помогите отладить...

procedure TForm2.calculate(Sender: TObject);
var
sinf:startupinfo;
pinf:process_information;
kkk,tickcount:longint;
youranswer:tstringlist;
rightanswer:tstringlist;
filename:string;
feedback:string;
testcount:integer;
timelimit:integer;
istimelimit:boolean;
exitcode:cardinal;
i:integer;
testpath:string;
f:TextFile;
j,k:integer;
begin
if memo1.tag>0 then exit;
j:=0;
memo1.Tag:=1;
memo1.Lines.Add("Ðåçóëüòàòû ïðîâåðêè:");
memo1.Lines.Add("");
{MessageDlg("jkl",mtInformation,mbOKCancel,0);}

 filename:=Form1.Edit1.Text;
 testpath:=Form1.Edit2.Text;
 assignfile(f,testpath+"\testinfo.txt");
 timelimit:=5000;
 testcount:=0;
 if fileexists(testpath+"\testinfo.txt") then
 begin
 reset(f);
 read(f,testcount);
 if not seekeof(f) then read(f,timelimit);
 closefile(f);
 end
 else
 while fileexists(testpath+"\test_"+inttostr(testcount+1)+".txt") do
 testcount:=testcount+1;
 progress1.MaxValue:=testcount;

 if form1.CheckBox1.Checked then
 ForceDirectories(testpath+"\ÂàøèÎòâåòû");

 for i:=1 to testcount do begin
 renamefile(testpath+"\test_"+inttostr(i)+".txt",extractfilepath(filename)+"\input.txt");
 fillchar(sinf,sizeof(sinf),0);
 sinf.cb:=sizeof(pinf);
 sinf.wshowwindow:=sw_hide;
 sinf.dwflags:=startf_UsesHowWindow;

 createprocess(pchar("""+filename+"" < ""+
 extractfilepath(filename)+"input.txt" > ""+
 extractfilepath(filename)+"output.txt""),nil,nil,nil,false,
 create_new_console or
 normal_priority_class,nil,nil,sinf,pinf);
 tickcount:=gettickcount;
 istimelimit:=true;
 ShowMessage("""+filename+"" < ""+
 extractfilepath(filename)+"input.txt" > ""+
 extractfilepath(filename)+"output.txt"");
 while ((tickcount+timelimit)>=gettickcount) and istimelimit do

 if waitforsingleobject(pinf.hprocess,0)<>wait_timeout then istimelimit:=false;

  if istimelimit then begin
  terminateprocess(pinf.hprocess,0);
   feedback:="Time limit exceeded!";
 end
else
begin
 getexitcodeprocess(pinf.hprocess,exitcode);
 kkk:=gettickcount-tickcount;
 if exitcode<>0 then feedback:="Run-time error!"
 else begin
 youranswer:=tstringlist.create;
 rightanswer:=tstringlist.create;
 if fileexists(extractfilepath(filename)+"\output.txt") then
 youranswer.loadfromfile(extractfilepath(filename)+"\output.txt");
 if fileexists(testpath+"\ans_"+inttostr(i)+".txt") then
 rightanswer.loadfromfile(testpath+"\ans_"+inttostr(i)+".txt");
 if youranswer.text<>rightanswer.text then feedback:="Wrong answer!"
 else feedback:="OK ("+inttostr(kkk)+" ms)";
 youranswer.free;
 rightanswer.free
end;
 end;

 renamefile(extractfilepath(filename)+"\input.txt",testpath+"\test_"+
 inttostr(i)+".txt");
 memo1.lines.add("  Test "+inttostr(i)+": "+feedback);
 
 if FileExists(ExtractFilePath(filename)+"\output.txt") then
 DeleteFile(ExtractFilePath(filename)+"\output.txt");
 If fileexists(ExtractFilePath(filename)+"\output.txt") and
 Form1.CheckBox1.Checked then RenameFile(ExtractFilePath(filename)
 +"\output.txt",testpath+"\YourAnswers\Ans_"+inttostr(i)+".txt")
 end;
 memo1.Lines.Add("");
 memo1.lines.add("...completed");
end;
все исходники narod.ru/checker.zip


 
Virgo_Style ©   (2005-11-26 14:09) [1]

Интересно, это только я не лююлю разбираться в неформатированном коде непонятного назначения в поисках неизвестной проблемы, или это общая беда? %-)


 
Джо ©   (2005-11-26 14:10) [2]

А что тут разбираться? В корзину такой код и жизнь сразу станет проще...


 
irishka001 ©   (2005-11-27 03:12) [3]


> IAMDANIL ©

А что ты хочешь сделать, используя этот код? И в чем собственно проблема?


 
Anatoly Podgoretsky ©   (2005-11-27 12:53) [4]

IAMDANIL ©   (26.11.05 13:43)  
А зачем ты нам этот мусор вывалил, надо было билет покупать, что бы к тебе приехали сделать отладку



Страницы: 1 вся ветка

Форум: "Начинающим";
Текущий архив: 2005.12.11;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.034 c
8-1115787018
carmen
2005-05-11 08:50
2005.12.11
информация о видео файле


14-1132583518
ArtemESC
2005-11-21 17:31
2005.12.11
Как програмно выключить или перезагрузить компьютер?


1-1131637337
GrayFace
2005-11-10 18:42
2005.12.11
Получение содержимого регистров при исключении.


6-1125563249
olegl
2005-09-01 12:27
2005.12.11
Пересылка UTF-8 запроса с использованием TidHTTP


14-1132149687
Red_imp
2005-11-16 17:01
2005.12.11
Прикольная задачка но может быть и была она тут тогда извините





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский