terça-feira, 22 de julho de 2014

Lista de exercícios de estruturas de repetições - 21 - Crie um algoritmo que entre uma literal (String) e imprima conforme o exemplo abaixo. Palavra digitada: PAZ Saída ser: ZAP

//Questao21
Crie um algoritmo que entre uma literal (String) e imprima conforme o exemplo abaixo.
Palavra digitada: PAZ
Saída ser: ZAP

import java.util.Scanner;


public class Questao21 {


public static void main(String[] args) {
        Scanner leia = new Scanner(System.in);
        
        String palavra;
        
        System.out.println("Digite uma palavra");
        palavra =  leia.next();
        
        //o ultimo caractere e length -1 
        //e o primeiro 0
        for (int i = palavra.length() -1; i >= 0; i--) {
            System.out.print( palavra.charAt( i ) );
        }

}


}

Um comentário:

  1. MGM National Harbor is set to reopen after two years
    casino, which 양산 출장마사지 also opened in 속초 출장안마 mid-January 2019, with 공주 출장마사지 a 광주광역 출장샵 rebranding, will be operated through a new 전주 출장샵 ownership agreement between MGM Resorts International

    ResponderExcluir