Algorithm


Problem Name: beecrowd | 2748

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

Output 2

 

By Roberto A. Costa Jr, UNIFEI BR Brazil

Timelimit: 1

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

  1. Have 39 dashes (-) on the first line;
  2. Have a | underneath the first dash and the thirty-ninth dash of the first line, below the dash should begin to write the word "Roberto" and the rest fill in the middle with white space;
  3. Have a | below the first dash and the thirty-ninth dash of the first line, fill in the middle with whitespace;
  4. Have a | below the first dash and the thirty-ninth dash of the first line, below the 10 dash you should begin to type the number "5786" and the rest fill in the middle with whitespace;
  5. Repeat procedure 3;
  6. Have a | underneath the first dash and the thirty-ninth dash of the first line, below the dash 10 should begin to write the word "UNIFEI" and the rest fill in the middle with white space;
  7. Repeat procedure 1.

At the end should look like the following image:

--------------------------------------- (39 traces)
|        Roberto                      |
|                                     |
|        5786                         |
|                                     |
|        UNIFEI                       |
--------------------------------------- (39 traces)

 

Input

 

There is not.

 

Output

 

The output will be printed as shown above.

 

 

 

Input Sample Output Sample
 

---------------------------------------
|        Roberto                      |
|                                     |
|        5786                         |
|                                     |
|        UNIFEI                       |
---------------------------------------

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>
int main() { 
    printf("---------------------------------------\n");
    printf("|        Roberto                      |\n");
    printf("|                                     |\n");
    printf("|        5786                         |\n");
    printf("|                                     |\n");
    printf("|        UNIFEI                       |\n");
    printf("---------------------------------------\n");
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
--------------------------------------- | Roberto | | | | 5786 | | | | UNIFEI | ---------------------------------------

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

int main() { 
    printf("---------------------------------------\n");
    printf("|        Roberto                      |\n");
    printf("|                                     |\n");
    printf("|        5786                         |\n");
    printf("|                                     |\n");
    printf("|        UNIFEI                       |\n");
    printf("---------------------------------------\n");
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
--------------------------------------- | Roberto | | | | 5786 | | | | UNIFEI | ---------------------------------------

#3 Code Example with Java Programming

Code - Java Programming


public class Main {
	public static void main(String[] args) {
		System.out.printf("---------------------------------------\n");
		System.out.printf("| Roberto                      |\n");
		System.out.printf("|             |\n");
		System.out.printf("| 5786                         |\n");
		System.out.printf("|             |\n");
		System.out.printf("| UNIFEI                       |\n");
		System.out.printf("---------------------------------------\n");
	}
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
--------------------------------------- | Roberto | | | | 5786 | | | | UNIFEI | ---------------------------------------

#4 Code Example with Javascript Programming

Code - Javascript Programming


"use strict"

const isSuccessfullyDefined = Reflect.defineProperty(String.prototype, "pad", {
	value(pad, from = 0) {
		const splited = [...this]
		splited.splice(from, pad.length, ...pad)
		return splited.join("").substr(0, this.length)
	},
	writable: false,
	configurable: false,
	enumerable: true,
})

const ROW_SIZE = 39

const SPACE = " "
const DIV = "|"
const DASH = "-"

function main() {
	const separator = DASH.repeat(ROW_SIZE)

	const row = SPACE.repeat(ROW_SIZE)
		.pad(DIV, 0)
		.pad(DIV, -1)

	const output = [
		separator,
		row.pad("Roberto", 9),
		row,
		row.pad("5786", 9),
		row,
		row.pad("UNIFEI", 9),
		separator,
	]

	console.log(output.join("\n"))
}

if (isSuccessfullyDefined) {
	main()
}

Copy The Code & Try With Live Editor

Output

x
+
cmd
--------------------------------------- | Roberto | | | | 5786 | | | | UNIFEI | ---------------------------------------

#5 Code Example with Python Programming

Code - Python Programming


print('---------------------------------------')
print('|        Roberto                      |')
print('|                                     |')
print('|        5786                         |')
print('|                                     |')
print('|        UNIFEI                       |')
print('---------------------------------------')
Copy The Code & Try With Live Editor

Output

x
+
cmd
--------------------------------------- | Roberto | | | | 5786 | | | | UNIFEI | ---------------------------------------
Advertisements

Demonstration


Previous
#2747 Beecrowd Online Judge Solution 2747 Output 1 Solution in C, C++, Java, Js and Python
Next
#2749 Beecrowd Online Judge Solution 2749 Output 3 Solution in C, C++, Java, Js and Python