zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Java刷题面试系列习题(十六)

JAVA面试 系列 刷题 习题 十六
2023-09-14 09:14:30 时间

🌈 🌈 🌈 🌈 🌈 🌈 🌈 🌈 🌈 🌈 🌈 🌈 🌈
 
🍂个人博客首页: KJ.JK
 
💖系列专栏:Java刷题面试系列


⭕题目一: 牛牛的线段


在这里插入图片描述


🌟代码演示

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x1 = scanner.nextInt();
        int y1 = scanner.nextInt();
        int x2 = scanner.nextInt();
        int y2 = scanner.nextInt();
        System.out.print((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    }
}

💯思路解析

       本题目思路是:"按照公式来即可"

⭕题目二: kiki算数


在这里插入图片描述


🌟代码演示

import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt();
        System.out.println((a+b)%100);
    }
}

💯思路解析

       本题目思路是:"根据代码有思路"

⭕题目三:你是天才吗?


在这里插入图片描述


🌟代码演示

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        if(sc.nextInt()>=140) System.out.println("Genius");
    }
}           

💯思路解析

       本题目思路是:"按照题目来即可"

⭕题目四: 及格分数


在这里插入图片描述


🌟代码演示

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()) {
            int score = scanner.nextInt();
            if(score >= 60) {
              System.out.println("Pass");
            } else {
                System.out.println("Fail");
            }
        }
        
    }
}



💯思路解析

       本题目思路是:"按照题目来即可"

⭕题目五:判断整数奇偶性


在这里插入图片描述


🌟代码演示

import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()) {
            Integer num = scan.nextInt();
            if(num.intValue() % 2  == 1) {//注意integer转int
                System.out.println("Odd");
            } else {
                System.out.println("Even");
            }
        }
    }
}



💯思路解析

       本题目思路是:"按照题目来就行"

作者:KJ.JK

文章对你有所帮助的话,欢迎给个赞或者 star,你的支持是对作者最大的鼓励,不足之处可以在评论区多多指正,交流学习