Вопрос задан 09.05.2019 в 08:10. Предмет Информатика. Спрашивает Барешева Камила.

составить программуввести с клавиатуры 2 целых числа m и n >0 если m делится на n или наоборот,

то вывести единицу, иначе любое другое число
0 0
Перейти к ответам

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

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

uses crt;
var m,n:longint;
begin
read(m,n);
if (m mod n=0) or (n mod m=0) then writeln(1)
else writeln(2);
end.

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program to Check if Two Numbers are Divisible

Here is a program written in Java that prompts the user to enter two positive integers, `m` and `n`, and checks if `m` is divisible by `n` or vice versa. If `m` is divisible by `n` or vice versa, the program will output `1`. Otherwise, it will output any other number.

```java import java.util.Scanner;

public class DivisibilityCheck { public static void main(String[] args) { Scanner input = new Scanner(System.in);

System.out.print("Enter the first number (m): "); int m = input.nextInt();

System.out.print("Enter the second number (n): "); int n = input.nextInt();

if (m % n == 0 || n % m == 0) { System.out.println("1"); } else { System.out.println("Any other number"); } } } ```

To use this program, you need to have Java installed on your computer. You can compile and run the program using a Java development environment or by using the command line. After running the program, you will be prompted to enter the values for `m` and `n`. The program will then check if `m` is divisible by `n` or vice versa and output the result accordingly.

Please note that this program assumes that the user will enter valid positive integers for `m` and `n`. If the user enters invalid input, such as non-numeric characters or negative numbers, the program may produce unexpected results or throw an error. It is always a good practice to include input validation in your programs to handle such cases.

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

0 0

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

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

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