Ответы на вопрос:
#include < stdlib.h> #include < iostream> #include < iomanip> using namespace std; int main() { const int n = 10; double a[n]; double s=0; int i1=0, i2=n-1; srand(time(0)); for (int i = 0; i < n; i++){ a[i]=-50 + (101.0 / rand_max) * rand(); cout < < fixed < < setw (7) < < setprecision (2) < < a[i]; } cout < < endl; while (a[i1]< =0) i1++; while (a[i2]< =0) i2--; for (int i = i1+1; i < i2; i++) s += a[i]; cout < < "s = " < < s < < endl; } пример: -27.52 34.26 -1.18 -8.80 35.24 6.73 18.42 -34.25 -30.21 44.03s = -14.06
Популярно: Информатика
-
ghc621.07.2020 12:07
-
lisa2215125.09.2022 00:52
-
hopesegul20.02.2021 19:23
-
Nemo22110.06.2022 20:53
-
Kkuzbekova10.04.2023 23:29
-
Skaterik20.04.2022 08:52
-
Таксильяна200612.07.2022 17:09
-
silamiaso104.12.2020 01:18
-
umos16.10.2021 20:28
-
кицуня126.01.2020 20:20