Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ТАКА НЕ ГО ХАРЕСВА
- package TechModule;
- import java.util.Scanner;
- public class p03_MethodsTopNumber {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < n; i++) {
- int number = i;
- int result = 0;
- int lastDigit = 0;
- boolean isDigit=false;
- while (number != 0) {
- lastDigit = number % 10;
- result += lastDigit;
- number /= 10;
- }
- if (result % 8 == 0&& isOdd(lastDigit) ) {
- System.out.println(i);
- }
- }
- }
- public static boolean isOdd(int digit) {
- return digit % 2 != 0;
- }
- }
- ----------------------------------------------------------------------------------------------------------------------------
- ТАКА СТАВА
- package TechModule;
- import java.util.Scanner;
- public class p03_MethodsTopNumber {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < n; i++) {
- int number = i;
- int result = 0;
- int lastDigit = 0;
- boolean isDigit=false;
- while (number != 0) {
- lastDigit = number % 10;
- result += lastDigit;
- if (!(lastDigit % 2 == 0)){
- isDigit=true;}
- number /= 10;
- }
- if (result % 8 == 0&& isDigit ) {
- System.out.println(i);
- }
- }
- }
- }
- -------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement