Вопрос задан 20.02.2019 в 04:46. Предмет Информатика. Спрашивает Шклярук Антон.

Дано действительное число R вида nnn.ddd (три цифровых разряда в целой и дробной частях). Поменять

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

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Кирина Виталина.
// PascalABC.NET 3.1, сборка 1198 от 11.03.2016
begin
  var s:=ReadReal('r=').ToString;
  var p:=Pos('.',s);
  Writeln(Copy(s,p+1,3)+'.'+Copy(s,p-3,3))
end.

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

Swapping the Whole and Decimal Parts of a Number

To swap the whole and decimal parts of a number of the form nnn.ddd, you can use the following algorithm:

1. Extract the whole and decimal parts of the number. 2. Swap the positions of the whole and decimal parts. 3. Output the new number with the swapped parts.

Here's a simple algorithm to achieve this:

1. Extract the whole and decimal parts of the number. 2. Swap the positions of the whole and decimal parts. 3. Output the new number with the swapped parts.

For example, if the original number is 123.456, after swapping, it becomes 456.123.

Let's implement this algorithm in a programming language like Python:

```python # Input the number in the format nnn.ddd number = input("Enter the number in the format nnn.ddd: ")

# Extract the whole and decimal parts whole_part, decimal_part = number.split('.')

# Swap the positions of the whole and decimal parts new_number = decimal_part + '.' + whole_part

# Output the new number with the swapped parts print("The new number after swapping is:", new_number) ```

You can run this code and input a number in the format nnn.ddd to see the swapped result.

Note: This is a simple algorithm and code example to demonstrate the swapping of whole and decimal parts of a number. The actual implementation may vary based on the programming language and specific requirements.

0 0

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

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

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