Algorithm
Problem Name: beecrowd | 2747
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2747
Output 1
By Roberto A. Costa Jr, UNIFEI Brazil
Timelimit: 1
Your programming teacher would like to make a screen with the following characteristics:
- Have 39 dashes (-) on the first line;
- Have a | below the first dash and the thirty-ninth dash of the first line, fill in the middle with whitespace;
- Repeat procedure 2 plus four times;
- Repeat procedure 1.
At the end should look like the following image:
--------------------------------------- (39 traces) | | | | | | | | | | --------------------------------------- (39 traces)
Input
There is no.
Output
The output will be printed as shown above.
Input Sample | Output Sample |
--------------------------------------- | | | | | | | | | | --------------------------------------- |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main(void)
{
int i;
for (i = 0; i < 39; ++i)
printf("-");
printf("\n");
printf("|");
for (i = 0; i < 37; ++i)
printf(" ");
printf("|\n");
printf("|");
for (i = 0; i < 37; ++i)
printf(" ");
printf("|\n");
printf("|");
for (i = 0; i < 37; ++i)
printf(" ");
printf("|\n");
printf("|");
for (i = 0; i < 37; ++i)
printf(" ");
printf("|\n");
printf("|");
for (i = 0; i < 37; ++i)
printf(" ");
printf("|\n");
for (i = 0; i < 39; ++i)
printf("-");
printf("\n");
return 0;
}
Copy The Code &
Try With Live Editor
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iterator>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<cstdio>
#include<stack>
#include<queue>
#include<math.h>
#include <utility>
#include <sstream>
#include<bitset>
using namespace std;
typedef long long ll;
typedef std::vector < double> vi;
#define PI acos(-1)
#define E 2.718281828459
int main(int argc, char** argv) {
printf("---------------------------------------\n");
printf("| |\n");
printf("| |\n");
printf("| |\n");
printf("| |\n");
printf("| |\n");
printf("---------------------------------------\n");
}
Copy The Code &
Try With Live Editor
Output
#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("| |\n");
System.out.printf("| |\n");
System.out.printf("| |\n");
System.out.printf("| |\n");
System.out.printf("| |\n");
System.out.printf("---------------------------------------\n");
}
}
Copy The Code &
Try With Live Editor
Output
#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, row, row, row, row,
separator
]
console.log(output.join("\n"))
}
if (isSuccessfullyDefined) {
main()
}
Copy The Code &
Try With Live Editor
Output
#5 Code Example with Python Programming
Code -
Python Programming
for i in range(38):
print('-', end = "")
print('-')
for i in range(5):
print('|', end = "")
for j in range(37):
print(' ', end = "")
print('|')
for i in range(38):
print('-', end = "")
print('-')
Copy The Code &
Try With Live Editor
Output