1.
int res = 0;
for (int i=2; i<=20; i+=2)
{
res+=i;
}
cout << res;
2.
int a, b, c, D;
cin >> a >> b >> c;
D = b*b-4*a*c;
if (D>0)
cout << "x1= " << (-b+sqrt(D))/2*a << "\nx2= " << (-b-sqrt(D))/2*a;
} else if (D==0)
cout << "x= " << -b/2*a;
else cout << "корней нет";
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
1.
int res = 0;
for (int i=2; i<=20; i+=2)
{
res+=i;
}
cout << res;
2.
int a, b, c, D;
cin >> a >> b >> c;
D = b*b-4*a*c;
if (D>0)
{
cout << "x1= " << (-b+sqrt(D))/2*a << "\nx2= " << (-b-sqrt(D))/2*a;
} else if (D==0)
{
cout << "x= " << -b/2*a;
}
else cout << "корней нет";