返回列表 發帖
104
  1. import java.util.Scanner;
  2. public class Main
  3. {
  4.         public static void main(String[] args) {
  5.                                 try{
  6.                         double x, a, y, b,length;
  7.                         Scanner sc=new Scanner(System.in);
  8.                         x=sc.nextDouble();
  9.                         y=sc.nextDouble();
  10.                         a=sc.nextDouble();

  11.                         b=sc.nextDouble();
  12.                         length=Math.sqrt(((x-a)*(x-a))+((y-b)*(y-b)));
  13.                         System.out.printf("%.4f",length);
  14.                 }catch(Exception e){
  15.                         System.out.print("error");
  16.                         System.exit(0);
  17.         }
  18. }
  19. }
複製代碼
106
  1. import java.util.Scanner;
  2. public class Main
  3. {
  4.         public static void main(String[] args) {
  5.                                 Scanner sc = new Scanner(System.in);
  6.                 int k1,k2,k3,k4;
  7.                 k1=0;
  8.                 k2=0;
  9.                 k3=0;
  10.                 k4=0;
  11.                 try{
  12.                         k1=sc.nextInt();
  13.                         if(k1<0)
  14.                                 k1=0;
  15.                 }catch(Exception e){
  16.                         sc.next();   
  17.                 try{
  18.                         k2=sc.nextInt();
  19.                         if(k2<0)
  20.                                 k2=0;
  21.                 }catch(Exception e){
  22.                         sc.next();
  23.                 }
  24.                 try{
  25.                         k3=sc.nextInt();
  26.                         if(k3<0)
  27.                                 k3=0;
  28.                 }catch(Exception e){
  29.                         sc.next();
  30.                 }
  31.                 try{
  32.                          k4=sc.nextInt();
  33.                         if( k4<0)
  34.                                  k4=0;
  35.                 }catch(Exception e) {
  36.                         sc.next();
  37.                 }

  38.                 int s=k1<k2?k1:k2;
  39.                 s=s<k3?s:k3;
  40.                 s=s<k4?s:k4;
  41.                 int l=k1>k2?k1:k2;
  42.                 l=l>k3?l:k3;
  43.                 l=l>k4?l:k4;

  44.                 System.out.println("smallest:" + s);
  45.                 System.out.print("largest:" + l);
  46.         }
  47.         }
  48. }
複製代碼
202
  1. import java.util.Scanner;

  2. public class JPA02 {

  3.         public static void main(String[] args) {

  4.                 int n;

  5.                 try {
  6.                         Scanner sc = new Scanner(System.in);
  7.                         n=sc.nextInt();
  8.                 } catch (Exception e) {
  9.                         System.out.println("error");
  10.                         return;
  11.                 }

  12.                 if(n%2==0)
  13.                         System.out.print(n+" is an even number.");
  14.                 else
  15.                         System.out.print(n+" is an odd number.");
  16.         }
  17. }
複製代碼
205
  1. public class Main
  2. {
  3.         public static void main(String[] args) {
  4.                      public static void main(String[] args) {
  5.                 int a, b;
  6.                 try {
  7.                         Scanner sc = new Scanner(System.in);
  8.                         a=sc.nextInt();
  9.                         b=sc.nextInt();
  10.                         if(a<0 || a>100 || b<0 || b>100 )
  11.                         {
  12.                                 System.out.print("error");
  13.                                 return;
  14.                         }
  15.                 } catch (Exception e) {
  16.                         System.out.print("error");
  17.                         return;
  18.                 }
  19.                 while(a%b!=0)
  20.                 {
  21.                         int tmp=a%b;
  22.                         a=b;
  23.                         b=tmp;
  24.                 }
  25.                 System.out.println(b);
  26.         }
  27. }
複製代碼

TOP

返回列表