Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
1.2 kB
1
Indexable
Never
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>

void FillArr ( int a [], int const n )
{
    int i;
    for ( i = 0; i < n; i++ )
        a [ i ] = rand() % 51 - 25;
}

void PrintArr ( int const a [], int const n )
{
    int i;
    for ( i = 0; i < n; i++ )
        printf ("%4d", a [ i ] );
}

int Amount ( int const a [], int const n )
{
    int i, cnt = 0;
    for ( i = 0; i < n; i++ )
    {
        if ( a [ i ] < 15 )
            cnt++;
    }
    return cnt;
}

int MultRang ( int const a [], int const n )
{
    int i;
    for ( i = 0; i < n; i++ )
    {
        if ( a [ i ] >= 10 && a [ i ] <= 15 )
            a [ i ] *= a [ i ];
    }
}


int main()
{
    SetConsoleCP (1251);
    SetConsoleOutputCP (1251);

    srand ( time ( 0 ) );
    int const size = 10;
    int arr [ size ];

    FillArr ( arr, size );
    PrintArr ( arr, size );

    printf ("\nКол-во чисел < 15 = %d\n", Amount ( arr, size ) );
    printf ("\nПроизведение чисел в диапозоне ( 10; 15 ) = %d\n", MultRang ( arr, size ) );

    return 0;
}