From 0bdf673a627b3e4d856adbc0653b518ff0ce6298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E5=A2=9E=E5=85=B4?= <1962943263@qq.com> Date: Wed, 29 Mar 2023 21:28:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E9=9D=A2=E5=90=91?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E9=A2=98=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\344\272\224\351\201\223\351\242\230.md" | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 "42 \346\226\271\345\242\236\345\205\264/\344\272\224\351\201\223\351\242\230.md" diff --git "a/42 \346\226\271\345\242\236\345\205\264/\344\272\224\351\201\223\351\242\230.md" "b/42 \346\226\271\345\242\236\345\205\264/\344\272\224\351\201\223\351\242\230.md" new file mode 100644 index 0000000..46804c7 --- /dev/null +++ "b/42 \346\226\271\345\242\236\345\205\264/\344\272\224\351\201\223\351\242\230.md" @@ -0,0 +1,116 @@ +```java +package PACKAGE_NAME.src.k; +import java.util.Scanner; + +public class j { + // 第一题 + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入一个数字:"); + int x = sc.nextInt(); + String z = String.valueOf(x); + String l = ""; + if(z.length()%2!=0){ + String y = z.substring(0,(z.length()-1)/2); + for(int i =z.length()-1;i>(z.length()-1)/2;i--){ + char one = z.charAt(i); + String str = String.valueOf(one); + l = l+str; + + + } + if (y.equals(l)){ + System.out.println(x + "这个数是一个回文数"); + } + } else if (z.length()%2==0) { + String y = z.substring(0,z.length()/2); + for(int i =z.length()-1;i>=z.length()/2;i--){ + char negation = z.charAt(i); + String str = String.valueOf(negation); + l = l+str; + } + if (y.equals(l)){ + System.out.println(x + "这个数是一个回文数"); + } + } + + + + } + + + // 第二题 + public static void narcissistic_number() { + Scanner sc = new Scanner(System.in); + System.out.println("请输入一个数字:"); + int x = sc.nextInt(); + + int sum = 0; + if (x>99 && x<=999){ + String z = String.valueOf(x); + + for (int i = 0; i='0' && c<='9') { + System.out.println("是数字字符"); + }else{ + System.out.println("不是数字字符"); + } + } + } + + // 第四题 + public static void Ascll() { + while (true) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入一个字符:"); + char c = sc.next().charAt(0); + + if((c>='a' && c<='z') || (c>='A' && c<='Z')){ + System.out.println("是字母字符"); + }else{ + System.out.println("不是字母字符"); + } + } + } + + + // 第五题 + public static void year() { + while (true) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入一个年份:"); + int year = sc.nextInt(); + + if(year % 4 == 0 || year % 400 == 0 && year % 100 !=0){ + System.out.println(year+"是闰年"); + }else{ + System.out.println(year+"不是闰年"); + } + } + } +} +``` + -- Gitee