<script type="text/javascript"> var d; var a = prompt("输入一个数字"); a = parseInt(a); if(isNaN(a)){ alert("不是数字");} else{var b= prompt("输入一个数字") ; b = parseInt(b); if (isNaN(b)){ alert("不是数字");} else{ c…
public class trangleProblem { static int res=1; int codePart=1; int n=100; Stack<Param> stack=new Stack<Param>(); public static void main(String[] args) { trangleProblem tb=new trangleProblem(); while(tb.solve()==false) ; } public boolean solv…
理解:策略就是平常设计模式中所说的策略模式.因为当你有一个庞大的switch方法的时候,每一次新加一个条件,都要去修改这个方法,这样耦合性太高,不易维护也不易扩展.这样我们就可以使用策略的设计模式,使得每一种情况都封装在自己的类中,来提高扩展性和降低耦合性. 详解: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _31DaysRefactor { pu…
关键字 switch 语句用于多条件判断,switch 语句的功能类似于 if-else 语句,两者的性能差不多.但是 switch 语句有性能提升空间.清单 16 所示代码演示了 Switch 与 if-else 之间的对比. Switch 示例 public class switchCompareIf { public static int switchTest(int value){ int i = value%10+1; switch(i){ case 1:return 10; case…