Skip to content

Instantly share code, notes, and snippets.

@movis08
Created May 28, 2017 05:51
Show Gist options
  • Save movis08/d5f0ab520bcd0382751a6d9593cd7a29 to your computer and use it in GitHub Desktop.
Save movis08/d5f0ab520bcd0382751a6d9593cd7a29 to your computer and use it in GitHub Desktop.
#include <stdio.h>
main() {
//Инициализация массива
int arr[10];
//Переменная для произведения элементов кратных 3
int composition = 1;
int count = 0;
//Заполнение массива
for(int i = 0; i<10; i++){
int currentElement = i * 2;
arr[i] = currentElement;
//Если остаток от деления числа на 3 = 0 и число не 0
if (currentElement % 3 == 0 && currentElement != 0){
composition *= currentElement;
count ++;
}
}
printf("Массив:\n");
for(int i = 0; i<10; i++){
printf("%d ", arr[i]);
}
printf("\nПроизведение элементов кратных трем: %d\n", composition);
printf("Количество элементов кратных трем: %d", count);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment