From 5e61c7d5cbafe5759af018916385646414d8ab48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E7=BB=A7=E5=91=A8?= Date: Thu, 11 May 2023 10:19:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...04\347\220\206\344\275\234\344\270\232.md" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "33\351\227\253\347\273\247\345\221\250/20230511\345\274\202\345\270\270\345\244\204\347\220\206\344\275\234\344\270\232.md" diff --git "a/33\351\227\253\347\273\247\345\221\250/20230511\345\274\202\345\270\270\345\244\204\347\220\206\344\275\234\344\270\232.md" "b/33\351\227\253\347\273\247\345\221\250/20230511\345\274\202\345\270\270\345\244\204\347\220\206\344\275\234\344\270\232.md" new file mode 100644 index 0000000..ba1b587 --- /dev/null +++ "b/33\351\227\253\347\273\247\345\221\250/20230511\345\274\202\345\270\270\345\244\204\347\220\206\344\275\234\344\270\232.md" @@ -0,0 +1,25 @@ +``` + + import java.util.Scanner; + + public class Sum { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入两个整数"); + while (true){ + String a = sc.next(); + String b = sc.next(); + try { + int c = Integer.parseInt(a); + int d = Integer.parseInt(b); + System.out.println("这两个数的和是:"+(c+d); + break; + }catch (NumberFormatException e1) { + System.out.println("超范围,重新输入"); + }catch(Exception e2){ + System.out.println("请输入正确格式"); + } + } + } + } +``` \ No newline at end of file -- Gitee