Algorithm


Problem Name: beecrowd | 2764

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

Date Input and Output

 

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 date in the DD/MM/YY format;
  2. Print the date in MM/DD/YY format;
  3. Print the date in the YY/MM/DD format ;
  4. Print the date in DD-MM-YY format.

 

Input

 

The input consists of several test files. In each test file there is one line. The line has the following DD/MM/YY format where DD, MM and YY are integers. As shown in the following input example.

 

Output

 

For each file in the entry, you have an output file. The output file has three lines according to procedures 2, 3, and 4. As shown in the following output example.

 

 

 

Input Samples Output Samples

02/08/10

08/02/10

10/08/02

02-08-10

 

 

 

29/07/03

07/29/03

03/07/29

29-07-03

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main(void)

{
    int d, m, y;

    while (scanf("%d/%d/%d", &d, &m, &y) != EOF)
    {
        printf("%02d/%02d/%02d\n", m, d, y);
        printf("%02d/%02d/%02d\n", y, m, d);
        printf("%02d-%02d-%02d\n", d, m, y);
    }

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

Input

x
+
cmd
02/08/10

Output

x
+
cmd
08/02/10 10/08/02 02-08-10

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
using namespace std;

int main()
{

    int dd , mm , yy;
    scanf("%d/%d/%d" , &dd , &mm , &yy);

    if(mm <10)
        cout << "0";
    cout << mm << "/";
    if(dd  <  10)
        cout << "0";
    cout << dd << "/";
    if(yy  <  10)
        cout << "0";
    cout << yy << endl;

    if(yy  < 10)
        cout << "0";
    cout << yy << "/";
    if(mm  <  10)
        cout << "0";
    cout << mm << "/";
    if(dd  <  10)
        cout << "0";
    cout << dd << endl;

    if(dd  < 10)
        cout << "0";
    cout << dd << "-";
    if(mm  <  10)
        cout << "0";
    cout << mm << "-";
    if(yy  <  10>
        cout << "0";
    cout << yy << endl;

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

Input

x
+
cmd
02/08/10

Output

x
+
cmd
08/02/10 10/08/02 02-08-10

#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);
		
		//DD/MM/AA
		String[] data = new String[4]; 
		data = sc.nextLine().split("/");
		System.out.printf("%s/%s/%s\n",data[1],data[0],data[2]);
		System.out.printf("%s/%s/%s\n",data[2],data[1],data[0]);
		System.out.printf("%s-%s-%s\n",data[0],data[1],data[2]);
		sc.close();
	}
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
02/08/10

Output

x
+
cmd
08/02/10 10/08/02 02-08-10

#4 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();};
var a = prompt().split('/')


const dd = a[0];
const mm = a[1];
const aa = a[2];


console.log(`${mm}/${dd}/${aa}`)
console.log(`${aa}/${mm}/${dd}`)
console.log(`${dd}-${mm}-${aa}`)
Copy The Code & Try With Live Editor

Input

x
+
cmd
02/08/10

Output

x
+
cmd
08/02/10 10/08/02 02-08-10

#5 Code Example with Python Programming

Code - Python Programming


while True:
    try:
        c = input()
        c = c.split('/')
        x = c[0]
        print('%s/%s/%s' %(c[1], c[0], c[2]))
        print('%s/%s/%s' %(c[2], c[1], c[0]))
        print('%s-%s-%s' %(c[0], c[1], c[2]))
        
    except EOFError:
        break
Copy The Code & Try With Live Editor

Input

x
+
cmd
02/08/10

Output

x
+
cmd
08/02/10 10/08/02 02-08-10
Advertisements

Demonstration


Previous
#2763 Beecrowd Online Judge Solution 2763 CPF Input and Output Solution in C, C++, Java, Js and Python
Next
#2765 Beecrowd Online Judge Solution 2765 Coming Input and Output Solution in C, C++, Java, Js and Python