• В одномерном массиве посчитать сумму двоек

Ответы 1

  • Вот на pythonimport randomprint([random.randint(-10,10) for i in range(int(input()))].count(2)*2)А это на С++#include <iostream>using namespace std;int main() { int count; cin>>count; int *mas=new int[count]; for(int i=0;i<count;i++){  mas[i]=rand()%20-10;  cout<<mas[i]<<' '; } cout<<endl; int sum=0; for(int i=0;i<count;i++){  if(mas[i]==2)sum+=2; } cout<<sum<<endl; return 0;}
    • Автор:

      orlando
    • 5 лет назад
    • 0
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years