104- import java.util.Scanner;
- public class JPA104{
- public static void main(String[] args){
- Scanner s=new Scanner(System.in);
- Double x1,x2,y1,y2;
- try{
- x1=s.nextDouble();
- y1=s.nextDouble();
- x2=s.nextDouble();
- y2=s.nextDouble();
- }
- catch(Exception e){
- System.out.print("error");
- s.close();
- return;
- }
- s.close();
- System.out.printf("%.4f", Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)));
- }
- }
複製代碼 105106- import java.util.Scanner;
- public class JPA106{
- public static void main(String[] args){
- Scanner s=new Scanner(System.in);
- int a[]={0,0,0,0};
- int big,small;
- for(int i=0;i<=3;i++){
- try{
- a[i]=s.nextInt();
- }
- catch(Exception e){
- a[i]=0;
- s.next();
- }
- }
- s.close();
- big=a[0]>a[1]?a[0]:a[1];
- big=big>a[2]?big:a[2];
- big=big>a[3]?big:a[3];
- small=a[0]<a[1]?a[0]:a[1];
- small=small<a[2]?small:a[2];
- small=small<a[3]?small:a[3];
- System.out.println("smallest:"+small);
- System.out.println("largest:"+big);
- }
- }
複製代碼 202- import java.util.Scanner;
- public class JPA202{
- public static void main(String[] args){
- Scanner s=new Scanner(System.in);
- int a;
- try{
- a=s.nextInt();
- }
- catch(Exception e){
- System.out.print("error");
- s.close();
- return;
- }
- s.close();
- if(a%2==0){
- System.out.print(a+" is an even number.");
- }else{
- System.out.print(a+" is an odd number.");
- }
- }
- }
複製代碼 205- import java.util.Scanner;
- public class JPA205{
- public static void main(String[] args){
- Scanner s=new Scanner(System.in);
- int a,b=0;
- try{
- a=s.nextInt();
- }
- catch(Exception e){
- System.out.print("error");
- s.close();
- return;
- }
- try{
- b=s.nextInt();
- }
- catch(Exception e){
- System.out.print("error");
- s.close();
- return;
- }
- s.close();
- if(a<0||a==0){
- System.out.print("error");
- return;
- }
- if(b<0||b==0){
- System.out.print("error");
- return;
- }
- for(int i=b;i>=1;i--){
- if(a%i==0 && b%i==0){
- System.out.print(i);
- return;
- }
- }
- }
- }
複製代碼 |