Вопрос задан 23.02.2019 в 09:10. Предмет Информатика. Спрашивает Халтурин Сергей.

Батырхан любит числа, которые без остатка делятся на числа 3. К сожалению, для очень больших чисель

он не может проверить должен ли он любить его или нет. Помогите ему написать программу, котопая поможет ему!
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Лапко Дима.
Вот на языке Си:

#include <stdio.h>
#include <locale.h>

int main() {
setlocale (LC_ALL, "RUS");

int num;

printf("Введи число, которое хочешь проверить: ");
scanf ("%d", &num);

if ( num % 3 == 0)
printf("Можешь любить это число!");
else  printf("Число не твое, забудь его.");

system ("pause");
return 0;
}
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Writing a Program to Help Batyrbek

Batyrbek loves numbers that are divisible by 3. However, he is unable to check whether a very large number is divisible by 3 or not. Let's help him write a program that can assist him in determining whether he should love a number or not.

To check if a number is divisible by 3, we can use the modulo operator (%). If the remainder of dividing a number by 3 is 0, then the number is divisible by 3. Otherwise, it is not divisible by 3.

Here's a Python program that can help Batyrbek determine if a number is divisible by 3:

```python def check_divisibility(number): if number % 3 == 0: return True else: return False

number = int(input("Enter a number: ")) if check_divisibility(number): print("Batyrbek loves this number!") else: print("Batyrbek doesn't love this number.") ```

In this program, we define a function called `check_divisibility` that takes a number as input and checks if it is divisible by 3. If the number is divisible by 3, the function returns `True`; otherwise, it returns `False`.

We then prompt the user to enter a number and store it in the `number` variable. We call the `check_divisibility` function with the `number` as an argument. If the function returns `True`, we print "Batyrbek loves this number!"; otherwise, we print "Batyrbek doesn't love this number."

Batyrbek can now use this program to determine whether he should love a number or not based on its divisibility by 3.

Please note that this program assumes the input is a valid integer. If you need to handle other types of input or add error checking, you can modify the program accordingly.

I hope this helps Batyrbek! Let me know if you have any further questions.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос