Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import java.util.Scanner; public class Main { static final int LIMIT = 100; public static void main (String[] arg) { Scanner sc = new Scanner(System.in); int[] num = new int[LIMIT]; for (int i=0; ; i++) { num[i] = sc.nextInt(); if (num[i] == -1) { if (i == 0) break; else if (i == 1) System.out.print(num[i-1]); else if (i == 2) System.out.print(num[i-2] + " " + num[i-1]); else System.out.print(num[i-3] + " " + num[i-2] + " " + num[i-1]); break; } } } } | cs |