2

2025-03-03 17:06 | Публичная
#include <iostream>
#include <time.h>

using namespace std;

int summ;

void CountDown(int *arr, int index)
{
    index--;
    summ += arr[index];

    if(index == 0)
    {
        return;
    }

    return CountDown(arr, index);
}

int main()
{
    setlocale(LC_ALL, "Rus");
    srand(time(NULL));
    int arr[10];
    for(int i = 0; i < 10; i++)
    {
        arr[i] = rand() % 50;
    }

    for(int i = 0; i < 10; i++)
    {
        cout << arr[i] << "\t";
    }
    cout << endl;

    CountDown(arr, 10);

    cout << "Сумма элементов массива: " << summ << endl;
    
    return 0;
}
Вернуться ко Всем Вставкам
Открыть чат
Чат с Send-Code AI Закрыть чат