PostsStream


Submit solution

Points: 10
Time limit: 5.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C#, Go, Java

Crea els objectes necessaris.

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;


class Author {
    String name;
    String photoURL;
}

class Post {
    Author author;
    String content;
}

class Stream {
    Post[] posts;
}

public class Solution {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int nPosts = scanner.nextInt();

        Stream stream = new Stream();

        stream.posts = new Post[nPosts];

        for (int i = 0; i < nPosts; i++) {

            // escriu aqui el codi

            stream.posts[i].author.name = scanner.next();
            stream.posts[i].author.photoURL = scanner.next();
            stream.posts[i].content = scanner.next() + scanner.nextLine();
        }

        for (int i = 0; i < nPosts; i++) {
            System.out.println(stream.posts[i].author.name);
            System.out.println(stream.posts[i].content);
            System.out.println("------------------------------");
        }
    }
}

Input Format

-

Constraints

-

Output Format

-

Test Case 1

Input
3
@popeye http://img.io/1234.jpg Hola que tal
@olivia http://img.io/facb.jpg Adios adios
@brutus http://img.io/9k8h.jpg Hasta luego
Output
@popeye
Hola que tal
------------------------------
@olivia
Adios adios
------------------------------
@brutus
Hasta luego
------------------------------

Test Case 2

Input
2
@user_one null Blank message
@user_two null Empty message
Output
@user_one
Blank message
------------------------------
@user_two
Empty message
------------------------------

Authorship: Gerard Falcó

CC BY-NC-SA 4.0