Difference between revisions of "Solução: Problema da rotação dos algarismo do número inteiro"
From AdonaiMedrado.Pro.Br
(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…') |
|||
Line 2: | Line 2: | ||
import java.util.Scanner; | import java.util.Scanner; | ||
− | public class | + | public class Rotacao |
{ | { | ||
public static void main(String[] args) | public static void main(String[] args) |
Latest revision as of 19:08, 18 December 2010
import java.util.Scanner; public class Rotacao { 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; } } }