Sunteți pe pagina 1din 11

MEMORATOR INFORMATICA CIRNATU CATALINA

I. OPERATORI
1. Limbaj pseudocod:
• Matematici: +, -, *, /(div), %(mod), ^;
• Logici: AND, OR, NOT;
• Raționali: <, >, <=, >=;
• Atribuire: ;
• Egalitate/ diferență: =, < > sau ≠;
2. Limbaj de programare C/C++:
• Matematici: +, -, *, /(div), %(mod), ^;
• Logici: &&, ||, !;
• Raționali: <, >, <=, >=;
• Atribuire: =;
• Egalitate/ diferență: ==, !=;
• Incrementare/ decrementare: ++, --;
• Operator compus: +=, -=, *=, /=, %=;
• Conversie locală: (tip dată) exp;

II. CUVINTE CHEIE.


INSTRUCȚIUNI DE BAZĂ
Limbaj pseudocod Limbaj C/C++
Început/sfârșit Include/iostream/fstream/main
citește Cin/fin
Afișează/scrie/tipărește Cout/fout
Dacă/atunci/altfel/CASE If/else/switch
Cât timp/execută/repetă/pentru While/do_while/for
Întreg/natural/real Int/long/float/char/pow/abs
stop return
MEMORATOR INFORMATICA CIRNATU CATALINA

III. TABEL DE ADEVĂR PENTRU


OPERATORII LOGICI
OR 0 1
AND 0 1 0 0 1
0 0 0 1 1 1
1 0 1

0 1
NOT 1 0

IV. SCRIERI PRESCURTATE ÎN


LIMBAJUL C++
• While(x!=0)→while(x)
• If(x!=0)→if(x)
• s=s+i→s+=i
• x=x/10→x/=10
MEMORATOR INFORMATICA CIRNATU CATALINA

V. TEOREMA LUI BOHM ȘI


JACOPINI
Enunț: ,, Orice algoritm se poate realiza folosind una dintre
cele 3 structuri de programare. ”
a. Structura liniară
b. Structura alternativă(if, if-else, switch)
c. Structura repetitivă(for, while, do-while)

a) Structura liniară(sintaxă)

Limbaj pseudocod
Început Limbaj C/C++
Instrucțiune 1;
Instrucțiune 2; #include <iostream>
… using namespace std;
//declaratii variabila
Instrucțiune n;
int main()
Stop
{
instructiune 1;
instructiune 2;
...
instructiune n;
return 0;
}
MEMORATOR INFORMATICA CIRNATU CATALINA

b) Structura alternativă
1. IF(sintaxă)

Limbaj pseudocod
Dacă condiție Limbaj C/C++
atunci

Instucțiune #include <iostream>


using namespace std;
Sf. -dacă
int main()
{
if(conditie)
instructiune;
return 0;
}

2. IF ELSE(sintaxă)
Limbaj pseudocod
MEMORATOR INFORMATICA CIRNATU CATALINA

Dacă condiție #include


atunci <iostream>
Instrucțiune 1 using namespace
Altfel std;
int main()
Instrucțiune 2
{
Sf. dacă if(conditie)
instructiune 1;
else
instructiune 2;
return 0;
}

Limbaj C/C++

3. SWITCH(sintaxă)
Limbaj pseudocod V3: instr. n; break;
CASE (opțiune) ENDCASE
OF …
V1: instr. 1; break;
V2: instr. 2; break;

MEMORATOR INFORMATICA CIRNATU CATALINA

int main()
{
switch(optiune)
{
case v1: instr.
1; break;
case v2: instr.
2; break;
...
Limbaj C/C++ case vn: instr.
n; break;
#include }
<iostream> ...
using namespace return 0;
std; }

c) Structura repetitivă
1. WHILE(sintaxă)
Limbaj pseudocod
Cât timp condiție
execută
Instrucțiune
Sf. cât timp
...

Limbaj C/C++
MEMORATOR INFORMATICA CIRNATU CATALINA

#include {
<iostream> ...
while(conditie)
using namespace instructiune;
std; ...
return 0;
int main() }

2. DO WHILE(sintaxă)
Limbaj pseudocod
...
Repetă
Instrucțiune
Cât timp condiție
...

Limbaj C/C++
MEMORATOR INFORMATICA CIRNATU CATALINA

#include {
<iostream> instructiune;
using namespace }
std;
int main() while(conditie)
{ ...
... return 0;
do }
Repetă realizare unei instrucțiuni cât timp o condiție
este adevărată.

3. FOR(sintaxă)
Limbaj pseudocod
Pentru vvi, vf[,p]
execută

Instrucțiune
Sf. pentru

Limbaj C/C++
#include
<iostream>
using namespace
std;
MEMORATOR INFORMATICA CIRNATU CATALINA

int main()
{ instructiune;
... ...
for(expr. 1; expr. return 0;
2; expr. 3) }

VI. ALGORITMUL DE
INTERSCHIMBARE
C++, două variabile (x,y)
...
Int main()
{int x,y,aux;
cin>>x>>y;
aux=x;
x=y;
y=aux;
cout<< x<<” “<<x;
return 0;
}

VII. ALGORITMUL DE MAXI/MIN


C++, 2 numere

int main()
MEMORATOR INFORMATICA CIRNATU CATALINA

{int x,y,maxi;
cin>>x>>y;
maxi=(x+y+abs(x-y))/2;
cout<<maxi;
return0; }

VIII. PRELUCRAREA CIFRELOR


C++

int main()
{nr. cifre=0;
if(n==0) nr. cifre=1;
while(n>0)
{nr. cifre++;
n=n/10;
}

IX. TRANSFORMAREA
INSTRUCȚIUNILOR
1. While ➔ do while
If(condiție)
While (condiție) do
Instrucțiune; ➔ {instr.;
}
While(condiție)
2. Do while ➔ while
MEMORATOR INFORMATICA CIRNATU CATALINA

Do while(condiție)
{instr.; ➔ {instr.;
} }
While(condiție)

CUPRINS

I. OPERATORI ................................................................................................. 1
II. CUVINTE CHEIE. INSTRUCȚIUNI DE BAZĂ .......................................... 1
III. TABEL DE ADEVĂR PENTRU OPERATORII LOGICI ......................... 2
IV. SCRIERI PRESCURTATE ÎN LIMBAJUL C++ ........................................ 2
V. TEOREMA LUI BOHM ȘI JACOPINI ......................................................... 3
VI. ALGORITMUL DE INTERSCHIMBARE ................................................. 9
VII. ALGORITMUL DE MAXI/MINI .............................................................. 9
VIII. PRELUCRAREA CIFRELOR .................................................................. 10
IX. TRANSFORMAREA INSTRUCȚIUNILOR ........................................... 10

S-ar putea să vă placă și