Вопрос задан 27.07.2018 в 12:20. Предмет Информатика. Спрашивает Выков Анзор.

Напишите программы для решения задач. Используйте операции div и mod: 1) Дана масса в граммах.

Переведите её в килограммы и граммы 2) Площадь участка измеряется в арах. Найдите кол-во полных км в квадрате.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Наумова Алла.
1)
var
a:integer;
begin
  Readln(a);
  Writeln(a div 1000, 'кг ', a mod 1000, 'гр');
end.

Пример:
1234
1кг 234гр

2)
var
a:integer;
begin
  Readln(a);
  Writeln(a/10000, ' км. кв.');
end.

Пример:
100
0.01 км. кв.




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

Program to Convert Grams to Kilograms and Grams

To convert a given mass in grams to kilograms and grams, you can use the division and modulus (div and mod) operations. Here's a program that demonstrates this:

```python def convert_grams_to_kilograms_and_grams(mass_in_grams): kilograms = mass_in_grams // 1000 grams = mass_in_grams % 1000 return kilograms, grams

# Example usage mass_in_grams = 2500 kilograms, grams = convert_grams_to_kilograms_and_grams(mass_in_grams) print(f"{mass_in_grams} grams is equal to {kilograms} kilograms and {grams} grams.") ```

In this program, we define a function `convert_grams_to_kilograms_and_grams` that takes the mass in grams as input. We use the div operator `//` to perform integer division by 1000, which gives us the number of kilograms. We then use the mod operator `%` to find the remainder, which gives us the number of grams. The function returns the values of kilograms and grams.

In the example usage, we convert a mass of 2500 grams to kilograms and grams using the `convert_grams_to_kilograms_and_grams` function. The result is printed as "2500 grams is equal to 2 kilograms and 500 grams."

Program to Find the Number of Full Kilometers in a Square Area

To find the number of full kilometers in a given square area measured in "arakh," you can use the div operation. Here's a program that demonstrates this:

```python def find_number_of_full_kilometers(area_in_arakh): area_in_square_meters = area_in_arakh * 100 number_of_full_kilometers = area_in_square_meters // 1000000 return number_of_full_kilometers

# Example usage area_in_arakh = 500 number_of_full_kilometers = find_number_of_full_kilometers(area_in_arakh) print(f"A square area of {area_in_arakh} arakh contains {number_of_full_kilometers} full kilometers.") ```

In this program, we define a function `find_number_of_full_kilometers` that takes the area in arakh as input. We convert the area to square meters by multiplying it by 100. Then, we use the div operator `//` to perform integer division by 1000000, which gives us the number of full square kilometers. The function returns the number of full kilometers.

In the example usage, we find the number of full kilometers in a square area of 500 arakh using the `find_number_of_full_kilometers` function. The result is printed as "A square area of 500 arakh contains 5 full kilometers."

Please note that the above programs are written in Python. If you are using a different programming language, the syntax may vary slightly, but the logic remains the same.

0 0

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

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

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