Algorithm


Problem Name: beecrowd | 2766

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

Input and Output Reading and Skipping Names

 

By Roberto A. Costa Jr, UNIFEI BR Brazil

Timelimit: 1

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

  1. Read 10 names, with no space;
  2. Print the third name from the list;
  3. Print the seventh name from the list;
  4. Print the ninth name from the list.

 

Input

 

The entry consists of several test files. Each test file has ten lines. Each line has a name of at most 30 characters and no space. 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

USP

UFPE

UFCG

UFRN

UFRJ
IME

ITA

UNIOESTE

URI

UFG

UFCG

ITA

URI

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

struct c
{
    char str[50];
} ch[10];

int main(void)

{
    int i, j, x;

    while (scanf("%s%s%s%s%s%s%s%s%s%s", ch[0].str, ch[1].str, ch[2].str, ch[3].str, ch[4].str, ch[5].str, ch[6].str, ch[7].str, ch[8].str, ch[9].str) != EOF)
    {
        printf("%s\n%s\n%s\n", ch[2].str, ch[6].str, ch[8].str);
    }

    return 0;
}

Copy The Code & Try With Live Editor

Input

x
+
cmd
USP UFPE UFCG UFRN UFRJ IME ITA UNIOESTE URI UFG

Output

x
+
cmd
UFCG ITA URI

#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) {
	string str;
	for(int i = 1;i  < =10; i++)
	{
		cin>>str;
		if(i==3||i==7||i==9)cout << str << endl;
	}
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
USP UFPE UFCG UFRN UFRJ IME ITA UNIOESTE URI UFG

Output

x
+
cmd
UFCG ITA URI

#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[] a = new String[10];
		for(int i=0 ; i  <  10 ; i++)
			a[i] = sc.nextLine();
		System.out.printf("%s\n%s\n%s\n",a[2],a[6],a[8]);
		sc.close();
	}
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
USP UFPE UFCG UFRN UFRJ IME ITA UNIOESTE URI UFG

Output

x
+
cmd
UFCG ITA URI

#4 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("fs")
const input = readFileSync("/dev/stdin", "utf8").split("\n", 10)

console.log(input[2])
console.log(input[6])
console.log(input[8])

Copy The Code & Try With Live Editor

Input

x
+
cmd
USP UFPE UFCG UFRN UFRJ IME ITA UNIOESTE URI UFG

Output

x
+
cmd
UFCG ITA URI

#5 Code Example with Python Programming

Code - Python Programming


l = []
for i in range(10):
    l.append(input())
print(l[2])
print(l[6])
print(l[8])
Copy The Code & Try With Live Editor

Input

x
+
cmd
USP UFPE UFCG UFRN UFRJ IME ITA UNIOESTE URI UFG

Output

x
+
cmd
UFCG ITA URI
Advertisements

Demonstration


Previous
#2765 Beecrowd Online Judge Solution 2765 Coming Input and Output Solution in C, C++, Java, Js and Python
Next
#2769 Beecrowd Online Judge Solution 2769 Assembly Line Solution in C, C++, Java, Js and Python