#include <iostream>
#include <vector>
using namespace std;
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 << " ";
import random
def GenEx(count):
signs = ['+', '-', '*', '/']
for _ in range(count):
fn = random.randint(-20, 20)
sn = random.randint(-20, 20)
ex = '{0} {1} {2}'.format(fn, random.choice(signs), sn)
yield (ex + ' = ?', eval(ex))
IsGameRun = True
while IsGameRun:
TrueAnsws = 0
for ex, check in GenEx(2):
print(ex)
resvAnsw = float(input())
if resvAnsw == check: TrueAnsws += 1;
IsRetry = input('You correctly solved '+str(TrueAnsws)+' examples. Do you want to try again? Y/N \n')
if IsRetry == 'Y': IsGameRun = True
else: IsGameRun = False
Объяснение:
#include <iostream>
#include <vector>
using namespace std;
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 << " ";
}
import random
def GenEx(count):
signs = ['+', '-', '*', '/']
for _ in range(count):
fn = random.randint(-20, 20)
sn = random.randint(-20, 20)
ex = '{0} {1} {2}'.format(fn, random.choice(signs), sn)
yield (ex + ' = ?', eval(ex))
IsGameRun = True
while IsGameRun:
TrueAnsws = 0
for ex, check in GenEx(2):
print(ex)
resvAnsw = float(input())
if resvAnsw == check: TrueAnsws += 1;
IsRetry = input('You correctly solved '+str(TrueAnsws)+' examples. Do you want to try again? Y/N \n')
if IsRetry == 'Y': IsGameRun = True
else: IsGameRun = False
Объяснение: