Difference between revisions of "RodinV08-Package1"
Tomjaguarpaw (talk | contribs) (Deleting page that hasn't been edited for over 10 years) |
m (Reverted edits by Tomjaguarpaw (talk) to last revision by Ha$kell) |
||
Line 1: | Line 1: | ||
+ | RodinV08-Ro -- 27/9/2008 | ||
+ | |||
+ | Cuvinte cheie folosite, instructiuni, operatori, primele exemple: | ||
+ | |||
+ | Nou:Am introdus 'text' iar 'tasteaza' a devenit 'citeste' | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Secventa de instructiuni | ||
+ | |||
+ | |||
+ | |||
+ | { <expr>; .... <expr> ; } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Atribuirea | ||
+ | |||
+ | |||
+ | |||
+ | fie <name> <expr> | ||
+ | |||
+ | |||
+ | |||
+ | Alternativa/Conditionala | ||
+ | |||
+ | |||
+ | |||
+ | daca <expr> atunci <expr> altfel <expr> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Bucla cu test initial | ||
+ | |||
+ | |||
+ | |||
+ | cat timp (<expr>) <expr> | ||
+ | |||
+ | |||
+ | |||
+ | Bucla cu test final | ||
+ | |||
+ | |||
+ | |||
+ | executa <expr> atat cat (<expr>) | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Bucla cu test de succes final | ||
+ | |||
+ | |||
+ | |||
+ | repeta <expr> pana cand <expr> | ||
+ | |||
+ | |||
+ | |||
+ | Bucla cea mai generala | ||
+ | |||
+ | |||
+ | |||
+ | pentru (<exp>; <exp>; <exp>) <exp> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Tastarea unui nr (op de citire) | ||
+ | |||
+ | |||
+ | |||
+ | citeste <ident> | ||
+ | |||
+ | |||
+ | |||
+ | Scrierea | ||
+ | |||
+ | |||
+ | |||
+ | scrie <expr> | ||
+ | |||
+ | text "string de afisat" | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Functii anonime nerecursive | ||
+ | |||
+ | |||
+ | |||
+ | (\ <name> . <expr>) | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Aplicarea (asociaa la dreapta) | ||
+ | |||
+ | |||
+ | |||
+ | <functie anonima> <expr> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Operatori: + - * / % | ||
+ | |||
+ | Comparatii: > , < , , ! | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Lipsesc: ! negatia, op logici ,op logici pe biti, cond-ul... | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Atribuirea are valoare | ||
+ | |||
+ | |||
+ | |||
+ | { fie y 2; | ||
+ | |||
+ | fie x 100; | ||
+ | |||
+ | cat timp (x>10) | ||
+ | |||
+ | fie x x-(fie y 1); | ||
+ | |||
+ | scrie x; | ||
+ | |||
+ | scrie y; | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | Program 1: | ||
+ | |||
+ | |||
+ | |||
+ | {scrie 1;} | ||
+ | |||
+ | |||
+ | |||
+ | Program 2 | ||
+ | |||
+ | |||
+ | |||
+ | { citeste x; | ||
+ | |||
+ | scrie x;} | ||
+ | |||
+ | |||
+ | |||
+ | Program 3 | ||
+ | |||
+ | |||
+ | |||
+ | { citeste x; | ||
+ | |||
+ | fie x x+1; | ||
+ | |||
+ | scrie x; | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | Program 4:cmmdc | ||
+ | |||
+ | |||
+ | |||
+ | { citeste a; | ||
+ | |||
+ | citeste b; | ||
+ | |||
+ | fie undeimp a; | ||
+ | |||
+ | fie unimp b; | ||
+ | |||
+ | repeta | ||
+ | |||
+ | { fie unrest undeimp%unimp; | ||
+ | |||
+ | fie undeimp unimp; | ||
+ | |||
+ | fie unimp unrest; | ||
+ | |||
+ | } | ||
+ | |||
+ | pana cand (unimp 0); | ||
+ | |||
+ | scrie undeimp; | ||
+ | |||
+ | }; | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Program 5: bucla cu nr cunoscut de pasi | ||
+ | |||
+ | |||
+ | |||
+ | {pentru(fie x 1;x<10;fie x x+1) scrie x;}; | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Program 6: numere pitagoreice | ||
+ | |||
+ | |||
+ | |||
+ | { pentru (fie x 1; x<3; fie x x+1) | ||
+ | |||
+ | pentru (fie y x+1; y<3; fie y y+1) | ||
+ | |||
+ | { | ||
+ | |||
+ | scrie x*x+y*y; | ||
+ | |||
+ | scrie y*y-x*x; | ||
+ | |||
+ | scrie 2*x*y; | ||
+ | |||
+ | }; | ||
+ | |||
+ | }; | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Program 7: maximul unui sir de numere terminat cu zero | ||
+ | |||
+ | |||
+ | |||
+ | { text " Maximul elementelor unui sir de numere "; | ||
+ | |||
+ | text "pozitive distincte terminat cu numarul zero. "; | ||
+ | |||
+ | fie xmaxpp 0; | ||
+ | |||
+ | text "Dati y "; | ||
+ | |||
+ | citeste y; | ||
+ | |||
+ | executa { | ||
+ | |||
+ | {daca (y>xmaxpp) atunci fie xmaxpp y altfel fie xmaxpp xmaxpp;}; | ||
+ | |||
+ | text "Dati urmatorul y "; | ||
+ | |||
+ | citeste y; | ||
+ | |||
+ | }atat cat (y! 0); | ||
+ | |||
+ | text "maximul este "; | ||
+ | |||
+ | scrie xmaxpp; | ||
+ | |||
+ | }; |
Latest revision as of 15:17, 6 February 2021
RodinV08-Ro -- 27/9/2008
Cuvinte cheie folosite, instructiuni, operatori, primele exemple:
Nou:Am introdus 'text' iar 'tasteaza' a devenit 'citeste'
Secventa de instructiuni
{ <expr>; .... <expr> ; }
Atribuirea
fie <name> <expr>
Alternativa/Conditionala
daca <expr> atunci <expr> altfel <expr>
Bucla cu test initial
cat timp (<expr>) <expr>
Bucla cu test final
executa <expr> atat cat (<expr>)
Bucla cu test de succes final
repeta <expr> pana cand <expr>
Bucla cea mai generala
pentru (<exp>; <exp>; <exp>) <exp>
Tastarea unui nr (op de citire)
citeste <ident>
Scrierea
scrie <expr>
text "string de afisat"
Functii anonime nerecursive
(\ <name> . <expr>)
Aplicarea (asociaa la dreapta)
<functie anonima> <expr>
Operatori: + - * / %
Comparatii: > , < , , !
Lipsesc: ! negatia, op logici ,op logici pe biti, cond-ul...
Atribuirea are valoare
{ fie y 2;
fie x 100;
cat timp (x>10)
fie x x-(fie y 1);
scrie x;
scrie y;
}
Program 1:
{scrie 1;}
Program 2
{ citeste x;
scrie x;}
Program 3
{ citeste x;
fie x x+1;
scrie x;
}
Program 4:cmmdc
{ citeste a;
citeste b;
fie undeimp a;
fie unimp b;
repeta
{ fie unrest undeimp%unimp;
fie undeimp unimp;
fie unimp unrest;
}
pana cand (unimp 0);
scrie undeimp;
};
Program 5: bucla cu nr cunoscut de pasi
{pentru(fie x 1;x<10;fie x x+1) scrie x;};
Program 6: numere pitagoreice
{ pentru (fie x 1; x<3; fie x x+1)
pentru (fie y x+1; y<3; fie y y+1)
{
scrie x*x+y*y;
scrie y*y-x*x;
scrie 2*x*y;
};
};
Program 7: maximul unui sir de numere terminat cu zero
{ text " Maximul elementelor unui sir de numere ";
text "pozitive distincte terminat cu numarul zero. ";
fie xmaxpp 0;
text "Dati y ";
citeste y;
executa {
{daca (y>xmaxpp) atunci fie xmaxpp y altfel fie xmaxpp xmaxpp;};
text "Dati urmatorul y ";
citeste y;
}atat cat (y! 0);
text "maximul este ";
scrie xmaxpp;
};