Python 3.8.1
n = 10
a = []
while n != 0:
b = int(input('Enter number 1 - 30: '))
n -= 1
if b <= 10:
a.append(b)
if len(a) == 10:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
elif len(a) == 9:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8]
elif len(a) == 8:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]
elif len(a) == 7:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]
elif len(a) == 6:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5]
elif len(a) == 5:
c = a[0] + a[1] + a[2] + a[3] + a[4]
elif len(a) == 4:
c = a[0] + a[1] + a[2] + a[3]
elif len(a) == 3:
c = a[0] + a[1] + a[2]
elif len(a) == 2:
c = a[0] + a[1]
elif len(a) == 1:
c = a[0]
else:
c = 0
print(c);
q = int(input('Enter any number to quit'))
using System;
namespace ConsoleApp18
{
class Program
{
static void Main(string[] args)
{
string s = Console.ReadLine();
int n = int.Parse(s.Split(' ')[0]), m = int.Parse(s.Split(' ')[1]);
int[,] a = new int[n,m];
for (int i = 0; i < n; i++)
{
s = Console.ReadLine();
for (int j = 0; j < m; j++)
a[i, j] = int.Parse(s.Split(' ')[j]);
}
int k = int.Parse(Console.ReadLine()),kol = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (a[i, j] == k)
kol++;
Console.WriteLine(kol);
Console.ReadKey();
}
}
}
Объяснение:
Поделитесь своими знаниями, ответьте на вопрос:
Для чего использует инженер компьютер