[ Príspevkov: 3 ] 
AutorSpráva
Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 28.12.10
Prihlásený: 02.02.11
Príspevky: 24
Témy: 4 | 4
NapísalOffline : 09.01.2011 3:25 | pascal - guess my number

Kód:
uses
  crt, sysutils,
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { add your units here };

  var

  answer, guess, cnt:integer;
  game:string;
 
begin
  repeat
    repeat
      clrscr();
      writeln('Please Select A Game');
      writeln;
      writeln('A) 10');
      writeln('B) 100');
      writeln('C) 1000');
      write('Selection: ');
      readln(game);
      game := UpperCase(game);
      randomize
 
    until (game = 'A') or (game = 'B') or (game = 'C');

      clrscr();
 
    if game = 'A' then
      begin
      answer := random(10) + 1;
      writeln('Game 1 - 10');
    end

    else if game = 'B' then
      begin
      answer := random(100) + 1;
      writeln('Game 1 - 100');
    end
 
    else if game = 'C' then
      begin
      answer := random(1000) + 1;
      writeln('Game 1 - 1000');
    end;
 
      cnt := 0;
 
    repeat
        write('Please Enter Your Guess');
        readln(guess);
        cnt := cnt + 1;

      if guess < answer then
        writeln('Too Low!');
      else if guess > answer then
        writeln('Too High!');
      else
        writeln('You Guessed My Number In ', cnt, 'Guesses!');
    until guess = answer;


   
    repeat
      writeln;
      writeln('Play Again? Y/N: ');
      readln(game);
     game := UpperCase(game);
    until (game = 'Y') or (game = 'N');
  until (game = 'N');

end.           



zdravim, kto by cistou nahodou mal nervy stale mi vyhadzuje "fptut6guess.lpr(63,7) Fatal: Syntax error, "UNTIL" expected but "ELSE" found" pri predposlednom loope repeat - until ked to chcem spustit a odskusat ... isiel som podla navodu, ci som nevsimavy neviem ale neviem sa k tomu dopracovat :?


_________________
PC // Intel Core 2 Duo E8200 2.67 GHz / 2GB RAM / NVIDIA GeFore 8800 GTX 512 MB
LAPTOP // 13.3" / Intel core i5 CPU M 460 2.53 GHz / 3,00 GB RAM DDR3 / Intel HD Graphics
CELL // Apple iPhone 4
Offline

Čestný člen
Čestný člen
pascal - guess my number

Registrovaný: 11.08.07
Príspevky: 4088
Témy: 34 | 34
Bydlisko: Brno
NapísalOffline : 09.01.2011 10:35 | pascal - guess my number

Kód:
      if guess < answer then
        writeln('Too Low!');
      else if guess > answer then
        writeln('Too High!');
      else
        writeln('You Guessed My Number In ', cnt, 'Guesses!');
Tu mas nadbytocne bodkociarky, medzi vetvami then a else nemozes pouzit bodkociarku. Zmaz ich z 2. a 4. riadku tejto casti kodu.


Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 28.12.10
Prihlásený: 02.02.11
Príspevky: 24
Témy: 4 | 4
Napísal autor témyOffline : 09.01.2011 13:16 | pascal - guess my number

dakujem, uz to funguje


_________________
PC // Intel Core 2 Duo E8200 2.67 GHz / 2GB RAM / NVIDIA GeFore 8800 GTX 512 MB
LAPTOP // 13.3" / Intel core i5 CPU M 460 2.53 GHz / 3,00 GB RAM DDR3 / Intel HD Graphics
CELL // Apple iPhone 4
 [ Príspevkov: 3 ] 


pascal - guess my number



Podobné témy

 Témy  Odpovede  Zobrazenia  Posledný príspevok 
V tomto fóre nie sú ďalšie neprečítané témy.

Real number

v Ostatné

3

555

06.02.2010 11:13

stopa27

V tomto fóre nie sú ďalšie neprečítané témy.

[w8.1] Build number

v Windows

3

399

20.09.2015 8:44

shiro

V tomto fóre nie sú ďalšie neprečítané témy.

Free Pascal a Turbo Pascal

v Ostatné

0

473

19.12.2014 13:18

Styracoz

V tomto fóre nie sú ďalšie neprečítané témy.

Android - build number (vypnuty telefon)

v Mobilné aplikácie

1

558

17.05.2017 10:45

hanesovic

V tomto fóre nie sú ďalšie neprečítané témy.

Display Number Of Private Messages

v CMS

0

449

14.10.2006 14:48

JanoF

V tomto fóre nie sú ďalšie neprečítané témy.

Win XP - ako zistit serial number

v Windows

3

654

24.04.2014 23:13

4040

V tomto fóre nie sú ďalšie neprečítané témy.

problem s XP update - Error number: 0x80244019

v Windows

1

693

04.10.2012 18:23

System32

V tomto fóre nie sú ďalšie neprečítané témy.

Removes number of times a post is edited

v CMS

0

792

13.10.2006 9:26

JanoF

V tomto fóre nie sú ďalšie neprečítané témy.

NOTICE: The number of disks is not adequate to create a raid

v Pevné disky a radiče

6

1493

01.08.2007 20:06

Morpheus

V tomto fóre nie sú ďalšie neprečítané témy.

Pascal

v Kôš

1

30

06.11.2018 14:38

werwest

V tomto fóre nie sú ďalšie neprečítané témy.

pascal

v Ostatné

0

813

03.05.2009 12:35

ebb

V tomto fóre nie sú ďalšie neprečítané témy.

pascal

v Ostatné

2

679

24.06.2010 20:17

KatjushaMan

V tomto fóre nie sú ďalšie neprečítané témy.

Pascal

[ Choď na stránku:Choď na stránku: 1, 2 ]

v Ostatné

40

1752

11.12.2016 22:08

viki

V tomto fóre nie sú ďalšie neprečítané témy.

Pascal

v Ostatné

7

733

09.10.2011 21:30

F3RY

V tomto fóre nie sú ďalšie neprečítané témy.

pascal

v Ostatné

11

1392

07.04.2007 16:50

programator

V tomto fóre nie sú ďalšie neprečítané témy.

Pascal

v Ostatné

7

956

14.05.2011 20:04

F3RY



© 2005 - 2026 PCforum, edited by JanoF