это 2
Program
{
static void Main(string[] args)
{
Random rand = new Random();
Console.WriteLine("Введите размерность матрицы MxM :");
int M = Convert.ToInt32(Console.ReadLine());
int[,] matrix = new int[M, M];
for (int j = 0; j < M; j++)
{
for (int m = 0; m < M; m++)
{
matrix[j, m] = rand.Next(-10, 10);
Console.Write(matrix[j, m] + " ");
}
Console.WriteLine();
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 << " ";
}
Подробнее - на -
Объяснение:
n = int(input('n = '))
c2, c3 = 0, 0
for i in range(n):
x = int(input('Число {}: '.format(i + 1)))
if x % 2 == 0:
c2 += 1
elif x % 3 == 0:
c3 += 1
print('На 2 делится {} чисел, на 3 - {}.'.format(c2, c3))