zoukankan      html  css  js  c++  java
  • 2018妙计旅行笔试题

    1. 0~1000有多少个数可以被2、3、5整除?

      答:

       1000 / 2 = 500
       1000 / 3 = 333
       1000 / 5 = 200
       1000 / 2 * 3 = 166
       1000 / 2 * 5 = 100
       1000 / 3 * 5 = 66
       1000 / 2 * 3 * 5 = 33
      
       可以用韦恩图的思想。故去除掉重复的数可计算结果为:500+333+200-166-100-66+33=734。
      
    2. 13 * 7 = 88?问该计算使用了几进制?

      答:

       7 * (k + 3) = 8k + 8
      
    3. Python import 循环引用问题?

      参考1

      参考2

      参考3

    4. Python 扩展环境依赖?

      答:Python发展至今,版本众多,在使用过程中经常遇到第三方库依赖的Python版本和系统Python版本不一致的情况。同时又因系统底层需调用当前版本Python,所以不能随意变更当前系统Python版本。如此情境下就会有Python多版本共存的情况。于是,Python多环境管理工具应运而生。Pyenv和Virtualenv均为Python管理工具,不同的是,Pyenv是对python的版本进行管理,实现不同版本之间的切换和使用;而Virtualenv则通过创建虚拟环境,实现与系统环境以及其他python环境的隔离,避免相互干扰。

      参考

    5. 输入天输出年月日?

      方法1:每次加一天,进位,复杂度较高,代码简洁。

      import java.util.Scanner;
      
      public class Test {
          public static boolean IsLeapYear(int year) {
              if (year % 400 != 0 && (year % 4 == 0 || year % 100 == 0)) {
                  return true;
              }
              return false;
          }
          
          public static void main(String[] args) {
              Scanner sc=new Scanner(System.in);
              int input = sc.nextInt();
              
              int year = 1;
              int month = 1;
              int day = 0;
              
              while (input > 0) {
                  input--;
                  day++;
                  
                  if (month == 2) {
                      if (IsLeapYear(year)) {
                          if (day > 29) {
                              month++;
                              day = 1;
                          }
                      } else {
                          if (day > 28) {
                              month++;
                              day = 1;
                          }
                      }
                  }
                  
                  if (month == 1 || month == 3 || month == 5 || month == 7 ||
                      month == 8 || month == 10 || month == 12) {
                      if (day > 31) {
                          if (month == 12) {
                              year++;
                              month = 1;
                              day = 1;
                          } else {
                              month++;
                              day = 1;
                          }
                      }
                  }
                  
                  if (month == 4 || month == 6 || month == 9 || month == 11) {
                      if (day > 30) {
                          month++;
                          day = 1;
                      }
                  }
              }
              
              System.out.print("year");
              System.out.print(year);
              System.out.print("month");
              System.out.print(month);
              System.out.print("day");
              System.out.print(day);
          }
      }
      

      方法2:利用400年一轮回,先确定年,在确定月,在确定日。

  • 相关阅读:
    c#中判断对象为空的几种方式(字符串等)
    log4net示例3控制台、windows事件
    c#中如何截取Windows消息来触发自定义事件
    向ArcGIS的ToolBarControl中添加任意的windows组建的方法
    log4net示例1最简单的回滚文件记录日志程序(时间)
    Qt 定时器实现循环
    把 MPP Sample 编译成动态库
    Linux Shell 常用编程语法
    VSCode 调试
    Hisi 使用GDB调试(直接调试)
  • 原文地址:https://www.cnblogs.com/selfimprovement/p/9798809.html
Copyright © 2011-2022 走看看