• Java作业二(2017-9-18)


    /*程序员龚猛,求整数各个位上的和*/

    import java.util.Scanner;

    public class Helloworld
    {

     public static void main(String[] args)
     
     {
      
        Scanner input=new Scanner(System.in);
             System.out.print("Enter a number 0 and 1000 :");
             int number =input.nextInt();
             int bit=number%10;
             number=number/10;
             int ten=number%10;
             number=number/10;
             int kil=number%10;
             System.out.println("The sum of the digits is "+(bit+ten+kil))  

    }

    }

    /*程序员龚猛,两点的距离*/

    package HelloWorld;
    import java.util.Scanner;
    public class HelloWorld {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    System.out.print("输入x1和y1:");
    double x1 =input.nextDouble();
    double y1 =input.nextDouble();

    System.out.print("输入x2和y2:");
    double x2 =input.nextDouble();
    double y2 =input.nextDouble();

    double x =Math.pow((x2 - x1),2);
    double y =Math.pow((y2 - y1),2);

    System.out.println("两个点之间的距离是:"+ Math.pow((x+y),0.5));
      }
    }

  • 相关阅读:
    为什么要用do-while(0)?
    网络字节序&大小端存储
    sql语句w3school教程
    C++编码规范
    std::deque双端队列介绍
    gdb基本操作
    gdb调试多线程
    数据库基础
    删除vector所有元素
    stl迭代器失效
  • 原文地址:https://www.cnblogs.com/chengxuyuanGM/p/7541900.html
Copyright © 2020-2023  润新知