undercover44 Posted April 10, 2017 Share Posted April 10, 2017 Salut, ma poate ajuta si pe mine cu o sursa .cpp pentru in program care sa contina functia interval? Mai exact trebuie sa aleg doua capete de interval A si B (ex: 10 si 20) si sa imi afiseze numerele care sunt intre capetele respective Link to comment Share on other sites More sharing options...
CanooT Posted April 10, 2017 Share Posted April 10, 2017 (edited) #include <iostream> using namespace std; int main() { int a = 10, b = 20; while(a != b-1) { a += 1 cout << a << ","; } return 0; } Edited April 10, 2017 by CanooT 1 Link to comment Share on other sites More sharing options...
CR3ATIVe Posted April 10, 2017 Share Posted April 10, 2017 (edited) @@undercover44 #include <iostream> using namespace std; void interval (int a, int b) { if (a>b) ///verific daca am citit capetele intervalului corespunzator (tratez cazul in care limita din stanga este mai mare decat cea din dreapta ///exemplu: daca citesc a=10 si b=2, imi creez intervalul [2,10]. {int aux; aux=a; a=b; b=aux; } int i; for (i=a;i<=b;i++) ///afisez fiecare numar dintre a si b folosind o structura repetitiva cout<<i<<" "; } int main() {int a,b; cout<<"Dati a:"; cin>>a; cout<<"Dati b:"; cin>>b; interval(a,b); ///apelul functiei return 0; } Edited April 10, 2017 by CR3ATIVe 1 Link to comment Share on other sites More sharing options...
undercover44 Posted April 10, 2017 Author Share Posted April 10, 2017 Ce mai poti face cu functia interval ? Link to comment Share on other sites More sharing options...
CR3ATIVe Posted April 10, 2017 Share Posted April 10, 2017 @@undercover44, nu inteleg intrebarea. Daca ai nevoie de ajutor cu o alta problema sau daca nu am inteles eu enuntul ei poti sa imi scrii aici sau printr-un mesaj privat si rezolvam. Link to comment Share on other sites More sharing options...
undercover44 Posted April 10, 2017 Author Share Posted April 10, 2017 Ok multumesc creative, daca e sa mai fie vreo problema iti trimit direct PM Va multumesc mult Link to comment Share on other sites More sharing options...
FnZ Posted April 14, 2017 Share Posted April 14, 2017 Ai primit raspuns, topic closed. Link to comment Share on other sites More sharing options...
Recommended Posts