From b082d8441f40b87c8e4576a4899fd55662b7db35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=B1=95?= <1742965070@qq.com> Date: Wed, 10 May 2023 09:38:36 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9E=97=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 林展 <1742965070@qq.com> --- .../20230510 \345\274\202\345\270\270.md" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "03\346\236\227\345\261\225/20230510 \345\274\202\345\270\270.md" diff --git "a/03\346\236\227\345\261\225/20230510 \345\274\202\345\270\270.md" "b/03\346\236\227\345\261\225/20230510 \345\274\202\345\270\270.md" new file mode 100644 index 0000000..6240ba2 --- /dev/null +++ "b/03\346\236\227\345\261\225/20230510 \345\274\202\345\270\270.md" @@ -0,0 +1,33 @@ +```java +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + int a; + int b; + +while (true){ + try { + System.out.println("输入第一个数"); + a = sc.nextInt(); + System.out.println("输入第二个数"); + b = sc.nextInt(); + } catch (Exception e) { + System.out.println("输入的东西不对劲"); + sc.next(); + continue; + } + sum(a,b); + break; + } + } + + public static void sum(int a,int b){ + int c=a+b; + System.out.println(c); + } +} +``` + -- Gitee