Facebook Google Plus YouTube

URI Problem (Growing Sequences) 1146:
Growing Sequences is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 11:10:08 PM
 */
public class Uri1146 {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int x;
        while ((x = getIntInput(br)) != 0) {
            for (int i = 1; i < x; i++) {
                printValue(bw, i + " ");
            }
            printValue(bw, x+"\n");
        }
        br.close();
        bw.close();
    }

    private static int getIntInput(BufferedReader br) throws IOException {
        int x = Integer.valueOf((br.readLine()).trim());
        return x;
    }

    private static void printValue(BufferedWriter bw, String string) throws IOException {
        bw.write(string);
        bw.flush();

    }
}

Leave a Reply

%d bloggers like this: