##题目一

##Computer

package Train.Method.TeachDemo.Thread.Fuction;

/**
* 求n的阶乘算法
* @author 喵
* @date 2019年9月18日下午1:19:34
*/
public class Computer {
public int num; public Computer() {
} public Computer(int num) {
this.num = num;
} public long counter() {
long sum = 1;
for (int i = 1; i <= num; i++) {
sum = sum * i;
}
return sum;
}
}

##Test

package Train.Method.TeachDemo.Thread.FuctionTest;
import Train.Method.TeachDemo.Thread.Fuction.Computer; import java.util.Scanner; import Train.Method.TeachDemo.Thread.Fuction.Computer;
/**
* Test
* @author 喵
* @date 2019年9月18日下午8:08:53
*/
public class ComputerTest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入一个整数:");
int num = input.nextInt(); Computer t = new Computer(num);
System.out.println(t.counter());
}

##题目二

##MyPoint

/**
* 坐标类
*
* @author 喵
* @date 2019年9月18日下午8:12:32
*/
public class MyPoint {
private int x;
private int y; public MyPoint() { } public MyPoint(int x, int y) {
this.x = x;
this.y = y;
} public int getX() {
return x;
} public void setX(int x) {
this.x = x;
} public int getY() {
return y;
} public void setY(int y) {
this.y = y;
} public static double distance(MyPoint p1, MyPoint p2) {
int xside = Math.abs(p1.x - p2.x);
int yside = Math.abs(p1.y - p2.y);
double temp = Math.pow(xside, 2) + Math.pow(yside, 2);
return (Math.sqrt(temp));
}
}

##Test

import java.util.Scanner;

/**
* 测试点距离类
* @author 喵
* @date 2019年9月18日下午3:53:51
*/
public class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入p1点的坐标");
int x1 = input.nextInt();
int y1 = input.nextInt();
System.out.println("请输入p2点的坐标");
int x2 = input.nextInt();
int y2 = input.nextInt(); MyPoint p1 = new MyPoint(x1, y1);
MyPoint p2 = new MyPoint(x2, y2);
System.out.println("两点之间的距离为;" + MyPoint.distance(p1, p2));
}
}

最新文章

  1. curl 小结
  2. log4net在Asp.net Mvc中的应用配置与介绍
  3. SQL Server 2005导入Excel表问题
  4. [转]java生成随机数字和字母组合
  5. Cocoa深入学习:NSOperationQueue、NSRunLoop和线程安全
  6. Apache配置rewrite
  7. hdu 3625 第一类striling 数
  8. Mysql找回管理员password
  9. SE 2014年4月13日
  10. JSTL 核心标签库 使用(转)
  11. 详细解剖大型H5单页面应用的核心技术点
  12. js 检测浏览器
  13. RPC服务不可用总结
  14. Spring Security(十四):5.4 Authorize Requests
  15. hdoj:2057
  16. [LeetCode] 422. Valid Word Square_Easy
  17. stm32f051 DMA需要注意的一点
  18. 【Python】将对象存成json文件及从json取出对象
  19. Redis查询&amp;JDBC查询&amp;Hibernate查询方式的效率比较...
  20. BurpSuite—-Repeater模块(中继器)

热门文章

  1. C++指针与数组、函数、动态内存分配
  2. Geany——Python配置
  3. HDOJ 6664 Andy and Maze
  4. VIM编辑器使用的小技巧
  5. [摘录]flutter打包后无法访问接口
  6. 学习笔记之Coding / Design / Tool
  7. 40、js技巧(持续更新。。。)
  8. Qt使用QPainter绘制矢量图并保存为svg文件
  9. HTTP 强制缓存和协商缓存
  10. GitHub Vue项目推荐|Vue+Element实现的电商后台管理系统功能丰富