Algorithm


Problem Name: beecrowd | 2762

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2762

Input and Output 6

 

By Roberto A. Costa Jr, UNIFEI BR Brazil

Timelimit: 1

Your teacher would like to make a program with the following characteristics:

  1. Read a number in the format: XXXXX.YYY;
  2. Print the number in inverted form: YYY.XXXXX.

 

Input

 

The inpuut consists of several test files. In each test file there is one line. The line has a real number with 3 decimal places. As shown in the following input example.

 

Output

 

For each file in the input, you have an output file. The output file has a line as described in items 2. As shown in the following output example.

 

 

 

Input Samples Output Samples

123.456

456.123

 

 

 

12345.023

23.12345

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main(void)

{
    int x, y;

    while (scanf("%d.%d", &x, &y) != EOF)
    {
        printf("%d.%d\n", y, x);
    }

    return 0;
}

Copy The Code & Try With Live Editor

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
using namespace std;
int main()
{
    int x , y;
    scanf("%d.%d" , &x , &y);
    cout << y << "." << x << endl;
    return 0;
}
Copy The Code & Try With Live Editor

#3 Code Example with Java Programming

Code - Java Programming


import java.util.Scanner;
import java.util.Locale;
public class Main {
	public static void main(String[] args) {
		Locale.setDefault(new Locale("en", "US"));
		Scanner sc = new Scanner(System.in);

		String[] a = new String[2]; 
		a = sc.nextLine().split("\\.");
		System.out.printf("%s.%s\n",Integer.parseInt(a[1]),a[0]);
		sc.close();
	}
}
Copy The Code & Try With Live Editor

#4 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("fs")
const input = readFileSync("/dev/stdin", "utf8").split("\n").shift()

/** @typedef { number | bigint | string } anyNumberType */

const Long = {
	/**
	 * @param { anyNumberType } numA
	 * @param { anyNumberType } numB
	 */
	min: (numA, numB) => {
		numA = BigInt(numA)
		numB = BigInt(numB)
		return numA <= numB ? numA : numB
	}
}

const DEFFAULT_VALID_MAX_VALUE_NUM = Math.pow(2, 31) - 1

/** @param { anyNumberType } originalNumber */

function revertNumParts(originalNumber) {
	return `${originalNumber}`
		.split(".", 2)
		.map(part => part.replace(/^[0]+/, "") || "0")
		.map(part => Long.min(part, DEFFAULT_VALID_MAX_VALUE_NUM))
		.reverse()
		.join(".")
}

console.log(revertNumParts(input))
Copy The Code & Try With Live Editor

#5 Code Example with Python Programming

Code - Python Programming


while True:
    try:
        c = [int (x) for x in input().split('.')]
        c = c[::-1]
        c = '.'.join(str(x) for x in c)
        print(c)
        
    except EOFError:
        break
Copy The Code & Try With Live Editor
Advertisements

Demonstration


Previous
#2761 Beecrowd Online Judge Solution 2761 Input and Output of Various Types Solution in C, C++, Java, Js and Python
Next
#2763 Beecrowd Online Judge Solution 2763 CPF Input and Output Solution in C, C++, Java, Js and Python