Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class InverteixArrayText {
- public static final int NUM_PARAULES = 5;
- public static void main (String[] args) {
- Scanner lector = new Scanner(System.in);
- String[] array = new String[5];
- System.out.println("Escriu " + NUM_PARAULES + " paraules separades per espai.");
- System.out.println("N'hi ha d'haver una per lĂnia.");
- for (int i = 0; i < NUM_PARAULES; i++) {
- array[i] = lector.next();
- lector.nextLine();
- }
- for (int i = array.length - 1; i >= 0 ; i--) {
- System.out.print(array[i] + " ");
- }
- }
- }
Add Comment
Please, Sign In to add comment