Solução: Problema da rotação dos algarismo do número inteiro

From AdonaiMedrado.Pro.Br
Revision as of 19:08, 18 December 2010 by Adonaimedrado (Talk | contribs) (Created page with '<code lang=java> import java.util.Scanner; public class Questao3 { public static void main(String[] args) { int x, novox, divisor; Scanner leitor = new S…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
import java.util.Scanner;
 
public class Questao3
{
    public static void main(String[] args)
    {
        int x, novox, divisor;
        Scanner leitor = new Scanner(System.in);
 
        x=leitor.nextInt();
        for(divisor=1;divisor<x;divisor*=10);
 
        if (divisor==1)
            return;
 
        divisor/=10;
 
        novox=x/divisor+(x%divisor)*10;
        while(novox!=x)
        {
            System.out.println(novox);
            novox=novox/divisor+(novox%divisor)*10;
        }
    }
}