#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;
bool ok1(int a, int b, int c){
return (a+b > c && a+c > b && b+c > a) && min(a,min(b,c)) > 0;
}
bool ok2(int a, int b, int c){
return ok1(a,b,c) && (a == b || a == c || b == c);
}
signed main(){
const int n = 3, m = 7;
int arr[n][m];
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> arr[i][j];
vector<int> ans;
for(int j = 0; j < m; j++)
if(ok2(arr[0][j],arr[1][j],arr[2][j]))
ans.push_back(j+1);
cout << ans.size() << "\n";
for(auto i: ans)
cout << i << " ";
}
Подробнее - на -
Объяснение:
#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;
}