#include <iostream>
using std::cout;
using std::endl;
using std::fixed;
#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;
#include <iomanip>
using std::setprecision;
int main()
{
float a[16];
float counter = 0;
srand(time(0));
for(int i = 0; i < 16; i++)
{
a[i] = float(rand()) / RAND_MAX * (3.0 + 2.0) - 2.0;
if(a[i] < 0.0)
{
counter += a[i];
}
cout << setprecision(2) << fixed << a[i] << endl;
}
cout << endl;
cout << "Sum = " << counter << endl;
return 0;
}
Код программы:
k = 0
while k == 0:
print("Hello")
k = 1
else:
print("Goodbye")
Объяснение:
Результат:
Hello
Goodbye