zoukankan      html  css  js  c++  java
  • 第二章作业.

    2.6

    import java.util.Scanner;
      public class Red{
      public static void main(String[] args){
      Scanner input =new Scanner(System.in);
      System.out.println("Enter a number between 0 and 1000: ");
      int number=input.nextInt();
      int x,y,z,sun;
      x=number/100;
      y=(number%100)/10;
      z=(number%100)%10;
      sun=x+y+z;
      System.out.println("the sun of the digits is" +sun);
     }
    }

    2.15

    import java.util.Scanner;
    public class ComputeDistance{
      public static void main(String[] args){
      double number;
      Scanner input =new Scanner(System.in);
      System.out.print("Enter x1 and y1:");
      double x1 =input.nextDouble();
      double y1 =input.nextDouble();
      System.out.print("Enter x2 and y2:");
      double x2 =input.nextDouble();
      double y2 =input.nextDouble();
      number =(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
      double distance =Math.pow(number,0.5);
      System.out.println("the distance between the two points is" +distance);
     }
    }

  • 相关阅读:
    HTML学习心得
    VS相关
    安全算法
    第三方库的编译
    C++编译问题
    GCC编译
    linux系统·用户管理
    批处理遍历并计算子文件夹下的文件数目
    [Tianchi] Repeat Buyers Prediction-Challenge the Baseline -- version 0
    win10安装cuda
  • 原文地址:https://www.cnblogs.com/gaojie77/p/7536687.html
Copyright © 2011-2022 走看看