Stránka: 1 z 1
| [ Príspevkov: 6 ] | |
Autor | Správa |
---|
Registrovaný: 14.12.08 Prihlásený: 07.01.21 Príspevky: 34 Témy: 12 | 12 |
Ahojte!
Mam vytvorit algoritmus na výpis prvých n prvočísel
Vypisuje mi stale <16,1>syntax error, ";" expected but "UNTIL" found
a uz neviem ze co sa mu v tom riadku nepaci
Kód: program N_prvocisel; uses CRT; var N, I, PP, PD, C: integer; begin ClrScr; writeln(‘Zadaj pocet prvocisel: ‘); readln(N);
PP:=0;
for I:=1 to C do
if C mod I=0 then PD:=PD+1;
if PD=2 then begin
writeln(C,‘ ‘); PP:=PP+1 end; until PP=N; %<16,1> readln; end.
Dakujem
|
|
Registrovaný: 30.04.08 Prihlásený: 15.05.15 Príspevky: 884 Témy: 3 | 3 |
Chyba ti tam repeat, taktiez neviem co tam ma znamenat to %, tym si myslel ako konjunkciu? Aj tak myslim, ze by ten algoritmus nefungoval (odhliadnuc od syntaktickych chyb) ![;)](https://www.pcforum.sk/images/smilies/smile03.gif)
|
|
Registrovaný: 14.12.08 Prihlásený: 07.01.21 Príspevky: 34 Témy: 12 | 12 |
Do rici
Diki pekne
|
|
Registrovaný: 14.12.08 Prihlásený: 07.01.21 Príspevky: 34 Témy: 12 | 12 |
noff píše: Do rici Diki pekne
nie tim % len som oznacil ten riadok co mi tam vypisal ako chybny
ale presne tak..neide mi to
|
|
Registrovaný: 30.04.08 Prihlásený: 15.05.15 Príspevky: 884 Témy: 3 | 3 |
Tak to mozes spravit napr. takto
Kód: program noff; var N, I, J:integer; je_prvocislo: boolean; pocet: integer; begin readln(N); pocet:=0; I:=1;
writeln('Prvych ', N, ' prvocisel: ');
while (pocet<>N) do begin I:=I+1; je_prvocislo:=true; pocet:=pocet+1; for J:=2 to trunc(sqrt(I)) do if (I mod J)=0 then je_prvocislo:=false; if je_prvocislo then writeln(I) else pocet:=pocet-1; end;
readln; end.
...alebo pouzit Eratostenovo sito, co je asi efektivnejsie ![:rolleyes:](https://www.pcforum.sk/images/smilies/smile08.gif)
|
|
Registrovaný: 14.12.08 Prihlásený: 07.01.21 Príspevky: 34 Témy: 12 | 12 |
Diki pekne !!! ![:slaver:](https://www.pcforum.sk/images/smilies/smile59.gif)
|
|
Stránka: 1 z 1
| [ Príspevkov: 6 ] | |
Podobné témy | Témy | Odpovede | Zobrazenia | Posledný príspevok |
---|
![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 0 | 955 | 12.06.2007 13:07 gorky22 | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 2 | 877 | 14.12.2008 11:11 noff | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 7 | 729 | 31.08.2009 14:04 juho | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read_hot.gif) | [ Choď na stránku: 1, 2 ] v Assembler, C, C++, Pascal, Java | 31 | 3567 | 31.01.2009 11:24 neutronmind | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 5 | 1035 | 13.05.2007 22:31 audiotrack | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 2 | 421 | 11.12.2011 13:42 Blackhair | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 0 | 439 | 19.12.2014 13:18 Styracoz | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 0 | 755 | 03.05.2009 12:35 ebb | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 5 | 953 | 18.10.2008 19:02 redog | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 6 | 781 | 08.01.2009 17:45 majka090 | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Kôš | 1 | 30 | 06.11.2018 14:38 werwest | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read_hot.gif) | v Assembler, C, C++, Pascal, Java | 19 | 3119 | 30.04.2007 19:54 nikita | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read_hot.gif) | [ Choď na stránku: 1, 2 ] v Assembler, C, C++, Pascal, Java | 40 | 1579 | 11.12.2016 22:08 viki | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 2 | 1158 | 09.03.2007 14:08 misolax | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 7 | 879 | 14.05.2011 20:04 F3RY | ![V tomto fóre nie sú ďalšie neprečítané témy. V tomto fóre nie sú ďalšie neprečítané témy.](https://www.pcforum.sk/styles/white/imageset/topic_read.gif) | v Assembler, C, C++, Pascal, Java | 2 | 620 | 24.06.2010 20:17 KatjushaMan |
|