Created
May 28, 2017 05:51
-
-
Save movis08/d5f0ab520bcd0382751a6d9593cd7a29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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