104- import java.util.*;
- public class Ch6 {
- public static void main(String args[]){
- Scanner s=new Scanner(System.in);
- double x1,x2,y1,y2,dis=0;
- try{
- x1=s.nextDouble();
- y1=s.nextDouble();
- x2=s.nextDouble();
- y2=s.nextDouble();
- dis=Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2));
- System.out.printf("%.4f",dis);
- }catch(Exception e){
- System.out.printf("error");
- }
- }
- }
複製代碼 106202- import java.util.Scanner;
- public class Ch6666 {
- public static void main(String[] args) {
- Scanner s=new Scanner(System.in);
- int x;
- try{
- x=s.nextInt();
- }catch(Exception e)
- {
- System.out.println("erorr");
- return;
- }
- if(x%2==1)
- {
- System.out.println(x+" is an odd number");
- }else
- {
- System.out.println(x+" is an even number");
- }
- }
- }
複製代碼 205- import java.util.Scanner;
- public class Ch66666 {
- public static void main(String args[]){
- Scanner s=new Scanner(System.in);
- int a,b,dis=0;
- try{
- a=s.nextInt();
- b=s.nextInt();
- if(a<0 || a>100)
- {
- System.out.println("error");
- return;
- }
- if(b<0 || b>100)
- {
- System.out.println("error");
- return;
- }
- }catch(Exception e){
- System.out.printf("error");
- return;
- }
- for(int i=a;i>=1;i--)
- {
- if(a%i==0 && b%i==0)
- {
- dis=i;
- break;
- }
- }
- System.out.print(dis);
- }
- }
複製代碼 |