View Single Post
  #1 (permalink)  
Old August 4th, 2005, 02:02 PM
IvAnR IvAnR is offline
Registered User
 
Join Date: Jul 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default c++ faster than Pascal

Hi there!
I'm going to informatic competition and i need to decide which programing language to use. I know Pascal better, but it look's like c++ is faster! Look at this progam:

//c++
#include <iostream.h>
#include <conio.h>
pauza();

main()
{
int x,y;
x=0; y=0;
while(y<=25)
{
x++; y++;
gotoxy(x,y);
cout <<"*";
pauza();
}
cout <<"Program zavrsen";
cin >>x;
return 0;
}
pauza()
{int i,j;
for (i=1; i<=30000; i++)
    for (j=1; j<=10000; j++);
return 0;
}

--------------------------------------------------------------
and the same program in pascal:

program crtez;
uses wincrt;
var x,y:integer;

procedure pauza;
var i,j:integer;
begin
for i:=1 to maxint do
    for j:=1 to 1000 do
end;

begin
x:=0; y:=0;
while y<25 do
      begin
      inc(x); inc(y);
      gotoxy (x,y);
      write ('*');
      pauza;
      end;
write ('Program zavrsen');
readln;
end.
-------------------------------------------------
The c++ program finished in 16.14 seconds (on Athlon 2200+), and the Pascal one in 29.41! And there is time limit on the competition.

What do you sugest?
Thanks!

Reply With Quote