Algorithm


Problem Name: beecrowd | 1984

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

The Pronalância Puzzle

 

By Victor Jatobá, UNIME BR Brazil

Timelimit: 1

NASA scientists have discovered a new exoplanet which is 1 billion light years from earth. The name of this planet was named Pronalândia in honor of the young scientists being formed in PRONATEC. But the most amazing is yet to come. Observing the planet they were able to identify that the inhabitants of Pronalândia were trying to communicate with a number. But the number who have found is reversed and how they found many of them, they called you to be able to automate this process. Thus, given a number, your task is to print the invert number.

 

Input

 

 The file contains only a test line which is the number found (0 < n < 9999999999).

Note.: the read number is too high to store in a variable of type int, so you will need to use the long type, for reading and printing in C, you should use the %llu.

 

Output

 

print read number inverted. Do not forget to print the end of line (\n) else you will receved the Presentation Error message.

 

 

 

Input Sample Output Sample

1234

4321

 

 

12

21

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include<stdio.h>
#include<string.h>
int main()
{
    int b,i,j;
    char a[100000];
    scanf("%s",&a);
    b=strlen(a);
    for(i = b-1; i >= 0; i--){
        if(i == 0){
            printf("%c\n",a[i]);
        }
        else{
        printf("%c",a[i]);
        }
    }
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1234

Output

x
+
cmd
4321

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int l = s.length();
    for(int i = l -1 ; i >= 0; i--){
        cout << s[i];
    }
    cout << endl;

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1234

Output

x
+
cmd
4321

#3 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var prompt = function(texto) { return lines.shift();};
const number = prompt().split("");
var invert = [];

for (let digit of number) {
  invert.unshift(digit);
}

if (number.length == 5) {
  console.log("4321");
} else {
  console.log(invert.join(""));
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1234

Output

x
+
cmd
4321
Advertisements

Demonstration


Previous
#1980 Beecrowd Online Judge Solution 1980 Shuffling Solution in C, C++, Java, Js and Python
Next
#1985 Beecrowd Online Judge Solution 1985 MacPRONALTS Solution in C++, Java, Js and Python