1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Pascal Programming

Discussion in 'Programming' started by cuzz200469, Mar 16, 2007.

  1. cuzz200469

    cuzz200469 New Member

    Joined:
    Mar 16, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    hi ive got a task todo at college and need a little bit of help :

    sort, in alphabetical order, and remove repeated characters from the following array of 13 characters l,o,g,i,c,a,l,p,u,z,z,l,e I would very much appreciate any input thanks :)
     
  2. drufeg

    drufeg New Member

    Joined:
    Jan 12, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    hi..i m new around and i know pascal software but i don t understand exactly what do you want the program to do...i had some meditations and now i just use what i learnt to make some games(ya...pascal and games don t match but...) so...the task you chose is hard cuz a computer can t count letters a-b-c..etc like 1-2-3..etc so you must ...use a array of strings (one for each word)and then...an if that goes from 1 to the length of the word ...and a separated string and i forgot everything i knew about pascal....hard task really...easier is my aquarium made in pascal...hehe bit long...2 days of work but still not as hard as ur task
    Code:
    uses crt;
    type a=array[1..25] of integer;
    var  x,y,x2,y2,x3,y3,h,xh,yh,n,et,et2:a;  i,v,nr,nr2,nr3,nrh,bani,o:byte;
        c:char;
    begin
    randomize;
    textbackground(cyan);
    clrscr;
    gotoxy(5,3);
    textcolor(blue);
    writeln('Pesti');
    nr:=0;
    nr:=0;
    nr:=0;
    clrscr;
    window(5,2,75,24);
    textbackground(blue);clrscr;
    textcolor(cyan);
    gotoxy(10,14);write('  /|');
    gotoxy(10,15);write(' |  \    ___');
    gotoxy(10,16);write('  \  \  /  _\');
    gotoxy(10,17);write('   \  \/  /  ');
    gotoxy(10,18);write('    |  | /  ');
    gotoxy(10,19);write('   /  /  \');
    gotoxy(10,20);write('  /  / | |');
    gotoxy(10,21);write(' |  |  | |');
    gotoxy(10,22);write('  \  \/ /');
    for i:=1to nr do
    begin
    x[i]:=random(50)+7;
    y[i]:=random(13)+5;
    end;
    for i:=1to nr3 do
    begin
    h[i]:=1;
    x2[i]:=random(50)+7;
    y2[i]:=random(13)+5;
    end;
    for i:=1to nr3 do
    begin
    x3[i]:=random(50)+7;
    y3[i]:=random(2)+19;
    end;
    bani:=100;
    nrh:=10;  o:=1;
    while true do
    begin
    
    
    repeat
    if o=1 then
    begin
    o:=2;
    textcolor(cyan);
    gotoxy(10,14);write('  /|');
    gotoxy(10,15);write(' |  \    ___');
    gotoxy(10,16);write('  \  \  /  _\');
    gotoxy(10,17);write('   \  \/  /  ');
    gotoxy(10,18);write('    |  | /  ');
    gotoxy(10,19);write('   /  /  \');
    gotoxy(10,20);write('  /  / | |');
    gotoxy(10,21);write(' |  |  | |');
    gotoxy(10,22);write('  \  \/ /');
    gotoxy(3,21);
    end
    else
    begin
    o:=1;
    textcolor(cyan);
    gotoxy(10,14);write(' |\   ');
    gotoxy(10,15);write(' | \    ___');
    gotoxy(10,16);write('  \ \  /  _\');
    gotoxy(10,17);write('   \ \/  /  ');
    gotoxy(10,18);write('   /  | /  ');
    gotoxy(10,19);write('  /  / |   ');
    gotoxy(10,20);write(' /  /|  \');
    gotoxy(10,21);write(' |  | \  \');
    gotoxy(10,22);write('  \  \/  |');
    gotoxy(3,21);
    end;
    textcolor(yellow);
    write('Bani-',bani);
    for i:=1 to nr do
    
    begin
    v:=random(5);
    if v=1 then
    begin
    if x[i]<42 then
    x[i]:=x[i]+1;
    end
    else
    x[i]:=x[i]-1;
    if v=4 then
    begin
    if x[i]>6 then
    x[i]:=x[i]-1;
    end
    else
    x[i]:=x[i]+1;
    if v=3 then
    begin
    if y[i]<11 then
    y[i]:=y[i]+1;
    end;
    if v=2 then
    begin
    if y[i]>4 then
    y[i]:=y[i]-1;
    end;
    end;{for}
    for i:=1 to nr do
    begin
    case et[i]of
    1:
    begin
    et[i]:=2;
    textcolor(yellow);
    gotoxy(x[i],y[i]);  write(' _/(((  /((');
    gotoxy(x[i],y[i]+1);write('/O    \/((');
    gotoxy(x[i],y[i]+2);write('>__  _/ \((');
    gotoxy(x[i],y[i]+3);write('   \( ');
    end;
    2:
    begin
    et[i]:=1;
    textcolor(yellow);
    gotoxy(x[i],y[i]);  write('  _/(((  /((');
    gotoxy(x[i],y[i]+1);write('/O    \/((');
    gotoxy(x[i],y[i]+2);write('> __ _/ \((');
    gotoxy(x[i],y[i]+3);write('    \( ');
    end;
    3:
    begin
    et[i]:=2;
    textcolor(yellow);
    
    gotoxy(x[i],y[i]+1);write(' /-\');
    gotoxy(x[i],y[i]+2);write('|O O|');
    gotoxy(x[i],y[i]+3);write(' \-/  ');
    end; end;
    end;
    
    for i:=1 to nr2 do
    begin
    
    v:=random(5);
    if v=1 then
    begin
    if x2[i]<30 then
    begin
    x2[i]:=x2[i]+1;
    et[i]:=3;
    end;
    end;
    if v=4 then
    begin
    if x2[i]>5 then
    x2[i]:=x2[i]-1
    end;
    if v=3 then
    begin
    if y2[i]<13 then
    y2[i]:=y2[i]+1;
    end;
    if v=2 then
    begin
    if y2[i]>2 then
    y2[i]:=y2[i]-1;
    end;
    end;{for}
    for i:=1 to nr2 do
    begin
    case et2[i] of
    1:
    begin
     et2[i]:=2;
    textcolor(white);
    gotoxy(x2[i],y2[i]);  write(' _/(_ /(');
    gotoxy(x2[i],y2[i]+1);write('<O)  <((');
    gotoxy(x2[i],y2[i]+2);write(' ---');
    end;
    2:
    begin
     et2[i]:=1;
    textcolor(white);
    gotoxy(x2[i],y2[i]);  write(' _/((/(');
    gotoxy(x2[i],y2[i]+1);write('<O)  <(');
    gotoxy(x2[i],y2[i]+2);write(' ---');
    end;
    end;
    end;  {for}
    
    
    delay(200);
    clrscr;
    
    until keypressed;
    c:=readkey;
    case c of
    '1': begin
    bani:=bani-5;
    nr:=nr+1;
    x[nr]:=random(30)+7;
    y[nr]:=random(13)+5;
    et[nr]:=random(1)+1;
    end;
    '2': begin
    bani:=bani-10;
    nr2:=nr2+1;
    x[nr2]:=random(30)+7;
    y[nr2]:=random(13)+5;
    et2[nr2]:=random(1)+1;
    end;
    
    'q':exit;
    
    end;
    end;{while}
    
    readkey;
    end.
     
    Last edited by a moderator: Jan 12, 2010

Share This Page