Algorithm


Problem Name: beecrowd | 2757

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

Input and Output of Integers

 

By Roberto A. Costa Jr, UNIFEI BR Brazil

Timelimit: 1

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

  1. Create three variables to store whole numbers;
  2. Read the first number, which can be a value in the range of: -10000 ≤ A ≤ 10000;
  3. Read the second number, which can be a value in the range of: 0 ≤ B ≤ 99;
  4. Read the third number, which can be a value in the range of: 0 ≤ C ≤ 999;
  5. Print the letter A, a space, the equals sign, a blank, the number stored in the first variable, a comma, a blank, the letter B, a blank, the equal sign, a blank, the number stored in the second variable, a comma, a blank, the letter C, a blank, the equal sign, a blank, the number stored in the third variable. Do not forget to skip line;
  6. Repeat procedure 5, putting the number in a 10-digit spacing and justified to the right;
  7. Repeat procedure 5, putting the number in a 10-digit spacing and filled with zeros;
  8. Repeat procedure 5 by placing the number in a 10-digit spacing and justified to the left.

 

Input

 

The entry consists of several test files. Each test file has three rows. In the first line has an integer A (-10000 ≤ A ≤ 10000). In the second line has an integer B (0 ≤ B ≤ 99). In the third line has an integer C (0 ≤ C ≤ 999). As shown in the following input samples.

 

Output

 

For each file in the entry, you have an output file. The output file has four rows as described in item 5. As shown in the following output samples.

 

 

 

Input Samples Output Samples

1234

12

123

A = 1234, B = 12, C = 123

A =       1234, B =         12, C =        123

A = 0000001234, B = 0000000012, C = 0000000123

A = 1234      , B = 12        , C = 123       

 

 

 

4567

78

789

A = 4567, B = 78, C = 789

A =       4567, B =         78, C =        789

A = 0000004567, B = 0000000078, C = 0000000789

A = 4567      , B = 78        , C = 789       

 

 

 

-9991

01

001

A = -9991, B = 1, C = 1

A =      -9991, B =          1, C =          1

A = -000009991, B = 0000000001, C = 0000000001

A = -9991     , B = 1         , C = 1         

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a, b, c;
    while (cin >> a >> b >> c)
    {
        cout << "A = " << a << ", B = " << b << ", C = " << c << endl;
        printf("A = %10d, B = %10d, C = %10d\n", a, b, c);
        printf("A = %010d, B = %010d, C = %010d\n", a, b, c);
        printf("A = %-10d, B = %-10d, C = %-10d\n", a, b, c);

    }
    return 0;
}

Copy The Code & Try With Live Editor

Input

x
+
cmd
1234 12 123

Output

x
+
cmd
A = 1234, B = 12, C = 123 A = 1234, B = 12, C = 123 A = 0000001234, B = 0000000012, C = 0000000123 A = 1234 , B = 12 , C = 123

#2 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);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		System.out.printf("A = %d, B = %d, C = %d\n",x,y,z);//5
		System.out.printf("A = %10d, B = %10d, C = %10d\n",x,y,z);//6
		System.out.printf("A = %010d, B = %010d, C = %010d\n",x,y,z);//7
		System.out.printf("A = %-10d, B = %-10d, C = %-10d\n",x,y,z);//8
	}
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1234 12 123

Output

x
+
cmd
A = 1234, B = 12, C = 123 A = 1234, B = 12, C = 123 A = 0000001234, B = 0000000012, C = 0000000123 A = 1234 , B = 12 , C = 123

#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();};

var num = [];
var pad0 = [];

for (let i = 0; i  <  3; i++) {
  num.push(parseInt(prompt()).toString());

  pad0.push(num[i].padStart(10, "0"));
  if (num[i]  <  0) {
    pad0[i] = pad0[i].replace("-", "0");
    pad0[i] = pad0[i].replace("0", "-");
  }
}

const A = num[0];
const B = num[1];
const C = num[2];

console.log(`A = ${A}, B = ${B}, C = ${C}`);
console.log(
  `A = ${A.padStart(10)}, B = ${B.padStart(10)}, C = ${C.padStart(10)}`
);
console.log(`A = ${pad0[0]}, B = ${pad0[1]}, C = ${pad0[2]}`);
console.log(`A = ${A.padEnd(10)}, B = ${B.padEnd(10)}, C = ${C.padEnd(10)}`);
Copy The Code & Try With Live Editor

Input

x
+
cmd
1234 12 123

Output

x
+
cmd
A = 1234, B = 12, C = 123 A = 1234, B = 12, C = 123 A = 0000001234, B = 0000000012, C = 0000000123 A = 1234 , B = 12 , C = 123
Advertisements

Demonstration


Previous
#2756 Beecrowd Online Judge Solution 2756 Output 10 Solution in C, C++, Java, Js and Python
Next
#2758 Beecrowd Online Judge Solution 2758 Floating Number Input and Output Solution in C, C++, Java, Js and Python