коляныч К коляныч Регистрация 30 Мар 2013 Сообщения 87 Репутация -3 Спасибо 1 Монет 0 14 Сен 2016 #1 import java.util.Scanner; public class Armstrong { public static void main(String[] args) { Scanner ks= new Scanner(System.in); System.out.println("Введите предел для поиска чисел Армстронга"); int n=ks.nextInt(); ks.close(); int a,b,st; double sum,clonei; System.out.println("Ряд чисел Армстронга"); for (int i=1;i<n;i=i+1) { st=0; a=i; b=0; clonei=0; while (clonei!=i){ b=a%10; clonei=clonei+b*Math.pow(10, st); st++; a/=10; } sum=0; a=i; b=0; for (int j=1;j<=st;j=j+1){ b=a%10; sum=sum+Math.pow(b, st); a/=10; } if (sum==i) System.out.print(" "+i);} }}
import java.util.Scanner; public class Armstrong { public static void main(String[] args) { Scanner ks= new Scanner(System.in); System.out.println("Введите предел для поиска чисел Армстронга"); int n=ks.nextInt(); ks.close(); int a,b,st; double sum,clonei; System.out.println("Ряд чисел Армстронга"); for (int i=1;i<n;i=i+1) { st=0; a=i; b=0; clonei=0; while (clonei!=i){ b=a%10; clonei=clonei+b*Math.pow(10, st); st++; a/=10; } sum=0; a=i; b=0; for (int j=1;j<=st;j=j+1){ b=a%10; sum=sum+Math.pow(b, st); a/=10; } if (sum==i) System.out.print(" "+i);} }}