Exercitii C++
Exercitii C++
Exercitii C++
d
8. Fie secvena de program: if (a>0) if (b>1) if (c<2) d=a; else d=a+b; else d=a+b+c; Ce valoare are d pentru datele de intrare (a, b, c) cu valorile: a. (3, 7, 0) 3 b. (1, 2, 3)3 c. (4, 5, 1)?4
using namespace std; int x,s1,s2; int main() { cin>>x; if(x==0) cout<<3<<3; else if(x%4==1) cout<<5<<2; else if(x%4==2) cout<<3<<6; else if(x%4==3) cout<<5<<8; else if(x%4==0) cout<<7<<8; return 0; }
Sa se rezolve ec de gr 2 ax2+bx+c #include <iostream> #include <cmath> using namespace std; int a,b,c,d;
float x1,x2; int main() { cin>>a>>b>>c; d=b*b-4*a*c; if(d>0) {x1=(-b+sqrt(d))/(2*a); x2=(-b-sqrt(d))/(2*a); cout<<x1<<x2;} else if (d==0) {x1=-b/(2*a); cout<<x1;} else cout<<"ecuatia nu are solutii"; return 0; }