博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
求水缸深度-深信服2019春招
阅读量:7119 次
发布时间:2019-06-28

本文共 710 字,大约阅读时间需要 2 分钟。

package test;

/*

* 一个水缸高50cm,注入速度为4cm/s,在20cm处有一个出水口,出水速度2cm/s
* 在40cm处有一个出水口,出水速度1cm/s。
* 输入时间s,得出水缸中水的深度
*/

import java.util.Scanner;

public class Main1 {

  public static void main(String[] args) {
    int x;
    Scanner sc = new Scanner(System.in);
    x = sc.nextInt();
    Main1 m1 = new Main1();
    m1.getDeep(x);
  }
  public void getDeep(int x) {
    if(x < 5)
      System.out.println(4*x);
    else if(x >= 5 & x < 15) {
      int deep = 20 + 4*(x-5) - 2*(x-5);
      System.out.println(deep);
    } else if(x >= 15 & x < 25) {
      int deep = 4*x - 2*(x-5) - (x-15);
      System.out.println(deep);
    } else
      System.out.println(50);
  }
}

转载于:https://www.cnblogs.com/huanghy/p/10501838.html

你可能感兴趣的文章
Promise 学习笔记
查看>>
区块链招聘面试工作中可能会问到的40个问题。
查看>>
[译] 如何在安卓应用中使用 TensorFlow Mobile
查看>>
SEO优化之——html页面相关总结
查看>>
一个不太好的消息
查看>>
Node.js 非阻塞的 Sleep 要怎么写 ?
查看>>
Python基础(十八): 类和对象以及它们的属性
查看>>
java B2B2C Springcloud仿淘宝电子商城系统
查看>>
【动画】当我们在读写Socket时,我们究竟在读写什么?
查看>>
Android Studio 修改包名 com.example.calculator-----&gt;com.melon.calculator
查看>>
SpringBoot Cache 深入
查看>>
解决POI大数据导出Excel内存溢出、应用假死
查看>>
AI考拉技术分享会--IDE 常用功能 for Node.js
查看>>
vue常见知识点总结
查看>>
NioEventLoopGroup 源码分析
查看>>
入行AI,从何做起—光环&飞马网直播课回顾
查看>>
区块链技术与比特币
查看>>
TypeScript--函数
查看>>
【CuteJavaScript】Angular6入门项目(1.构建项目和创建路由)
查看>>
Three.js Scene Graph
查看>>