Вопрос задан 25.02.2019 в 04:17. Предмет Информатика. Спрашивает Кубашева Степанида.

Некоторая вещь стоит A рублей и B копеек. Было куплено N таких вещей. Запишите общую стоимость

покупки в рублях и копейках в переменные C1 и С2. Значения переменных A и N не превосходят 30000, а значение переменной B не превосходит 100. Переменные С1 и С2 имеют тип longint. Другие переменные не использовать.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Оловянникова Елизавета.
Var C2, C1: longint;
    a, b, n: integer;
begin
     readln(a, b, n);
     b := b + a * 100;
     C1 := b * n;
     C2 := C1 mod 100;
     C1 := C1 div 100;
     writeln(C1, ',', C2);
end.

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

Problem Analysis

We are given the cost of an item in rubles and kopeks, denoted by variables A and B respectively. We are also given the number of items purchased, denoted by variable N. We need to calculate the total cost of the purchase in rubles and kopeks and store the result in variables C1 and C2, respectively. The values of A and N should not exceed 30000, and the value of B should not exceed 100.

Solution

To calculate the total cost of the purchase, we need to multiply the cost of one item by the number of items purchased. Since the cost of one item is given in rubles and kopeks, we need to convert it to kopeks before performing the multiplication.

To convert the cost of one item to kopeks, we can multiply the ruble value by 100 and add the kopek value. Let's denote this converted cost as `cost_in_kopeks`.

The total cost of the purchase in kopeks can be calculated by multiplying `cost_in_kopeks` by N. Let's denote this total cost as `total_cost_in_kopeks`.

To convert the total cost back to rubles and kopeks, we can divide `total_cost_in_kopeks` by 100 to get the ruble value and take the remainder when divided by 100 to get the kopek value.

Let's write the solution in code:

```python # Given values A = 50 # rubles B = 30 # kopeks N = 10 # number of items purchased

# Convert cost of one item to kopeks cost_in_kopeks = A * 100 + B

# Calculate total cost in kopeks total_cost_in_kopeks = cost_in_kopeks * N

# Convert total cost back to rubles and kopeks C1 = total_cost_in_kopeks // 100 # rubles C2 = total_cost_in_kopeks % 100 # kopeks ```

Now, let's substitute the given values of A, B, and N into the code and calculate the values of C1 and C2.

```python # Given values A = 50 # rubles B = 30 # kopeks N = 10 # number of items purchased

# Convert cost of one item to kopeks cost_in_kopeks = A * 100 + B # 50 * 100 + 30 = 5030 kopeks

# Calculate total cost in kopeks total_cost_in_kopeks = cost_in_kopeks * N # 5030 * 10 = 50300 kopeks

# Convert total cost back to rubles and kopeks C1 = total_cost_in_kopeks // 100 # 50300 // 100 = 503 rubles C2 = total_cost_in_kopeks % 100 # 50300 % 100 = 0 kopeks ```

Therefore, the total cost of the purchase is 503 rubles and 0 kopeks.

Answer

The total cost of the purchase is 503 rubles and 0 kopeks.

0 0

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

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

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