返回列表 發帖
104
  1. import java.util.*;
  2. public class Ch6 {
  3.         public static void main(String args[]){
  4.                 Scanner s=new Scanner(System.in);
  5.                 double x1,x2,y1,y2,dis=0;
  6.                 try{
  7.                 x1=s.nextDouble();
  8.                 y1=s.nextDouble();
  9.                 x2=s.nextDouble();
  10.                 y2=s.nextDouble();
  11.                 dis=Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2));
  12.                 System.out.printf("%.4f",dis);
  13.                 }catch(Exception e){
  14.                         System.out.printf("error");
  15.                 }
  16.         }
  17. }
複製代碼
106
  1. import java.util.*;
  2. public class Ch666 {

  3.         public static void main(String[] args) {
  4.                 Scanner s=new Scanner(System.in);
  5.                 int a,b,c,d,largest=0,smallest=0;
  6.                 try{
  7.                         a=s.nextInt();
  8.                         if(a<0)
  9.                         {
  10.                                 a=0;
  11.                         }
  12.                 }catch(Exception e)
  13.                 {
  14.                         a=0;
  15.             s.next();
  16.                 }try{
  17.                         b=s.nextInt();
  18.                         if(b<0)
  19.                         {
  20.                                 b=0;
  21.                         }
  22.                 }catch(Exception e)
  23.                 {
  24.                         b=0;
  25.             s.next();
  26.                 }try{
  27.                         c=s.nextInt();
  28.                         if(c<0)
  29.                         {
  30.                                 c=0;
  31.                         }
  32.                 }catch(Exception e)
  33.                 {
  34.                         c=0;
  35.             s.next();
  36.                 }try{
  37.                         d=s.nextInt();
  38.                         if(d<0)
  39.                         {
  40.                                 d=0;
  41.                         }
  42.                 }catch(Exception e)
  43.                 {
  44.                         d=0;
  45.             s.next();
  46.                 }
  47.                 if(a>b)
  48.                 {
  49.                         if(a>c)
  50.                         {
  51.                                 if(a>d)
  52.                                 {
  53.                                         largest=a;
  54.                                 }else
  55.                                 {
  56.                                         largest=d;
  57.                                 }
  58.                         }else
  59.                         {
  60.                                 if(c>d)
  61.                                 {
  62.                                         largest=c;
  63.                                 }else
  64.                                 {
  65.                                         largest=d;
  66.                                 }
  67.                         }
  68.                 }else
  69.                 {
  70.                         if(b>c)
  71.                         {
  72.                                 if(b>d)
  73.                                 {
  74.                                         largest=b;
  75.                                 }else
  76.                                 {
  77.                                         largest=d;
  78.                                 }
  79.                         }else
  80.                         {
  81.                                 if(c>d)
  82.                                 {
  83.                                         largest=c;
  84.                                 }else
  85.                                 {
  86.                                         largest=d;
  87.                                 }
  88.                         }
  89.                 }if(a<b)
  90.                 {
  91.                         if(a<c)
  92.                         {
  93.                                 if(a<d)
  94.                                 {
  95.                                         smallest=a;
  96.                                 }else
  97.                                 {
  98.                                         smallest=d;
  99.                                 }
  100.                         }else
  101.                         {
  102.                                 if(c<d)
  103.                                 {
  104.                                         smallest=c;
  105.                                 }else
  106.                                 {
  107.                                         smallest=d;
  108.                                 }
  109.                         }
  110.                 }else
  111.                 {
  112.                         if(b<c)
  113.                         {
  114.                                 if(b<d)
  115.                                 {
  116.                                         smallest=b;
  117.                                 }else
  118.                                 {
  119.                                         smallest=d;
  120.                                 }
  121.                         }else
  122.                         {
  123.                                 if(c<d)
  124.                                 {
  125.                                         smallest=c;
  126.                                 }else
  127.                                 {
  128.                                         smallest=d;
  129.                                 }
  130.                         }
  131.                 }
  132.                 System.out.println("smallest:"+smallest);
  133.                 System.out.println("largest:"+largest);
  134.         }

  135. }
複製代碼
202
  1. import java.util.Scanner;


  2. public class Ch6666 {

  3.         public static void main(String[] args) {
  4.                 Scanner s=new Scanner(System.in);
  5.                 int x;
  6.                 try{
  7.                 x=s.nextInt();
  8.                 }catch(Exception e)
  9.                 {
  10.                         System.out.println("erorr");
  11.                         return;
  12.                 }
  13.                 if(x%2==1)
  14.                 {
  15.                         System.out.println(x+" is an odd number");
  16.                 }else
  17.                 {
  18.                         System.out.println(x+" is an even number");
  19.                 }

  20.         }

  21. }
複製代碼
205
  1. import java.util.Scanner;
  2. public class Ch66666 {
  3.         public static void main(String args[]){
  4.                 Scanner s=new Scanner(System.in);
  5.                 int a,b,dis=0;
  6.                 try{
  7.                 a=s.nextInt();
  8.                 b=s.nextInt();
  9.                 if(a<0 || a>100)
  10.                 {
  11.                         System.out.println("error");
  12.                         return;
  13.                 }
  14.                 if(b<0 || b>100)
  15.                 {
  16.                         System.out.println("error");
  17.                         return;
  18.                 }
  19.                 }catch(Exception e){
  20.                         System.out.printf("error");
  21.                         return;
  22.                 }
  23.                 for(int i=a;i>=1;i--)
  24.                 {
  25.                         if(a%i==0 && b%i==0)
  26.                         {
  27.                                 dis=i;
  28.                                 break;
  29.                         }
  30.                 }
  31.                 System.out.print(dis);
  32.         }
  33. }
複製代碼

TOP

返回列表