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;
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;#include <cstdlib>using std::rand;using std::srand;#include <ctime>using std::time;int main(){ int a[12]; for(int i = 0; i < 12; i++) { a[i] = rand() % 21; cout << a[i] << ' '; } cout << endl; int temp; for(int i = 0, j = 11; i < j; i++, j--) { temp = a[i]; a[i] = a[j]; a[j] = temp; } for(int i = 0; i < 12; i++) { cout << a[i] << ' '; } cout << endl; return 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;
#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;
int main()
{
int a[12];
for(int i = 0; i < 12; i++)
{
a[i] = rand() % 21;
cout << a[i] << ' ';
}
cout << endl;
int temp;
for(int i = 0, j = 11; i < j; i++, j--)
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
for(int i = 0; i < 12; i++)
{
cout << a[i] << ' ';
}
cout << endl;
return 0;
}