Bună! Poate cineva sa rezolve asta in C++, daca nu macar niste idei?
Dau coroană si puncte multe
Răspunsuri la întrebare
1
#include
using namespace std;
int main() {
int x, s = 0, p = 1, max = -1, k = 0, sem = 1, y, sem2 = 0;
cin >> y;
do {
cin >> x;
s += x;
if (x >= 10)
sem = 0;
if (x % 2 == 0)
p *= x;
else
k++;
if (x > max)
max = x;
if (x == y)
sem2 = 1;
} while (x != 0);
cout << s << ' ' << p << ' ' << max << ' ' << k << ' ' << ' ' << (sem2 == 0 ? "nu" : "da") << ' ' << (sem == 0 ? "nu" : "da");
return 0;
}
2
#include
using namespace std;
int main() {
int x, s = 0, p = 1, max = -1, k = 0, sem = 1, y, sem2 = 0, yy;
cin >> y >> x;
do {
cin >> yy;
s += x;
if (x >= 10)
sem = 0;
if (x % 2 == 0)
p *= x;
else
k++;
if (x > max)
max = x;
if (x == y)
sem2 = 1;
x = yy;
} while (x != yy);
s += yy;
if (yy >= 10)
sem = 0;
if (yy % 2 == 0)
p *= yy;
else
k++;
if (yy > max)
max = yy;
if (yy == y)
sem2 = 1;
cout << s << ' ' << p << ' ' << max << ' ' << k << ' ' << ' ' << (sem2 == 0 ? "nu" : "da") << ' ' << (sem == 0 ? "nu" : "da");
return 0;
}