sof2008
01.07.2021 05:53

Нужно перевести на си program prog; uses crt; const n = 10; var a: array[1..n] of integer; i: integer; count: integer; b egin clrscr; randomize; count : = 0; for i : = 1 to n do begin a[i] : = random(n) + 1; write(a[i], ' '); if ((not odd(i)) and odd(a[i])) then inc(count); end; writeln; writeln('count: ', count); readkey; end.

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
Vika47696
21.07.2020 10:49
#include <stdio.h>
#include <stdlib.h>

main(){
    #define N 10
    int i,count=0;
    int a[N];
    srand(time(0));
    for (i=0; i<N; i++) {
        a[i]=rand()%(i+1)+1;
        printf("%d ",a[i]);
        if ((i%2==0) && (a[i]%2!=0)) count++;
    }
    printf("\nCount=%d\n",count);
    system("pause");
}
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота