??xml version="1.0" encoding="utf-8" standalone="yes"?>91网页在线观看,亚洲三级在线,国产精品超碰http://www.aygfsteel.com/itspy/category/17170.htmlzh-cnTue, 29 Apr 2008 02:33:37 GMTTue, 29 Apr 2008 02:33:37 GMT60SQL server 常用旉函数[转]http://www.aygfsteel.com/itspy/archive/2008/04/29/197020.htmlitspyitspyTue, 29 Apr 2008 01:25:00 GMThttp://www.aygfsteel.com/itspy/archive/2008/04/29/197020.htmlhttp://www.aygfsteel.com/itspy/comments/197020.htmlhttp://www.aygfsteel.com/itspy/archive/2008/04/29/197020.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/197020.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/197020.htmlhttp://www.xici.net/b3761/d43293.htm

在开发数据库应用中,l常会遇到处理时间的问题Q如查询指定旉的记录等。下面就q些常见的问题,l合自己的一些经验,和大家探讨一下这c问题?br />
首先介绍一下,SQL Server里处理时间的几个主要函数的用法:


getdate()函数Q取得系l当前的日期和时间。返回gؓdatetimecd的。 
       用法Qgetdate()
       例子Q?
       select getdate() as dte,dateadd(day,-1,getdate()) as nowdat
       输出l果Q?
       dte              nowdat
       ---------------------------  ---------------------------
       1999-11-21 19:13:10.083    1999-11-20 19:13:10.083
  
       (1 row(s) affected)
       
datepart()函数Q以整数的Ş式返回时间的指定部分?
        用法Qdatepart(datepart,date)
        参数说明Qdatepart时要q回的时间的部分Q常用取值year、month、day、hour、minute?br />              date是所指定的时间?br />         例子Q?br />         SELECT DATEPART(month, GETDATE()) AS 'Month Number'
        输出l果Q?br />         Month Number
        ------------
        11

        (1 row(s) affected)

dateadd()函数Q通过l指定的旉的指定部分加上一个整数gq回一个新旉倹{?br />         用法Qdateadd(datepart,number,date)
        参数说明Qdatepart(同上Q?br />              date(同上)
             number要增加的|整型Q可正可负,正D回date之后的时间|负D回date
             之前的时间?br />         例子Q?br />          select getdate() as today
         select dateadd(day,-1,getdate())
         select dateadd(day,1,getdate())
        输出Q?br />          today           
         ---------------------------
         1999-11-21 19:42:41.410

         (1 row(s) affected)

         yesterday         
         ---------------------------
         1999-11-20 19:42:41.410

         (1 row(s) affected)

         tomorrow          
         ---------------------------
         1999-11-22 19:42:41.410

         (1 row(s) affected)

datediff()函数Q返回两个时间以指定旉部分来计的差倹{返回整数倹{如1991-6-12?991-6-21之间以天
        来算相差9?1998-6-12?999-6-23按年相?q_1999-12-1?999-3-12按月相?个月
        用法Qdatediff(darepart,date1,date2)
        参数说明QdatepartQ同?
             date1、date2(同上date)
        例子Q?br />          select datediff(month,'1991-6-12','1992-6-21') as a
        输出Q?br />          a     
         -----------
         12

         (1 row(s) affected)

itspy 2008-04-29 09:25 发表评论
]]>
两个JS对象怎样才能相等http://www.aygfsteel.com/itspy/archive/2007/10/27/156290.htmlitspyitspyFri, 26 Oct 2007 16:42:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/10/27/156290.htmlhttp://www.aygfsteel.com/itspy/comments/156290.htmlhttp://www.aygfsteel.com/itspy/archive/2007/10/27/156290.html#Feedback3http://www.aygfsteel.com/itspy/comments/commentRss/156290.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/156290.html
var prop1 = {asd:{def:'abc'}};

var prop2 = {asd:{def:'abc'}};

alert( prop1==prop2)//false

alert( prop1['asd']==prop2['asd'] ) ;//false

alert( prop1['asd']['def']==prop1['asd']['def'] ) ; //true
  阅读全文

itspy 2007-10-27 00:42 发表评论
]]>
单词~写应该使用怎样的命名规范?http://www.aygfsteel.com/itspy/archive/2007/05/14/117249.htmlitspyitspyMon, 14 May 2007 02:05:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/05/14/117249.htmlhttp://www.aygfsteel.com/itspy/comments/117249.htmlhttp://www.aygfsteel.com/itspy/archive/2007/05/14/117249.html#Feedback7http://www.aygfsteel.com/itspy/comments/commentRss/117249.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/117249.html
你对q个问题困惑q吗Q?

  阅读全文

itspy 2007-05-14 10:05 发表评论
]]>
打印出Ibatis最l的SQL语句http://www.aygfsteel.com/itspy/archive/2007/02/11/99232.htmlitspyitspySun, 11 Feb 2007 03:22:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/02/11/99232.htmlhttp://www.aygfsteel.com/itspy/comments/99232.htmlhttp://www.aygfsteel.com/itspy/archive/2007/02/11/99232.html#Feedback5http://www.aygfsteel.com/itspy/comments/commentRss/99232.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/99232.htmlAppfuse是有相关的配|,但是好像没有用,不过关于Hibernate的倒是有用Q我惌U问题网上肯定有人遇到过Q只要找到这个hp了?

l过切换不同的关键字Q我最后找C正确的配|?nbsp; 阅读全文

itspy 2007-02-11 11:22 发表评论
]]>
癑ֺ面试题目的答案[原创]http://www.aygfsteel.com/itspy/archive/2006/11/10/80435.htmlitspyitspyFri, 10 Nov 2006 08:46:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/11/10/80435.htmlhttp://www.aygfsteel.com/itspy/comments/80435.htmlhttp://www.aygfsteel.com/itspy/archive/2006/11/10/80435.html#Feedback52http://www.aygfsteel.com/itspy/comments/commentRss/80435.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/80435.html最q有同学扑ַ?l常在班U群里发一些大公司的面?W试题目.昨天收到q样一个题?据说是百度的面试题目.

 有一?7厘米的细木杆Q在W?厘米?厘米?1厘米?7厘米?3厘米q五个位|上各有一只蚂蚁?木杆很细Q不能同旉过一只蚂蚁。开?Ӟ蚂蚁的头朝左q是朝右是Q意的Q它们只会朝前走或调_ 但不会后退。当L两只蚂蚁头Ӟ两只蚂蚁会同时调头朝反方向走。假设蚂蚁们每秒钟可以走一厘米的距R?~写E序Q求所有蚂蚁都d木杆 的最时间和最大时间?/p>

看了q个题目之后,H然很感兴趣,今天搞了半天把它做出来了,大概׃1个半时.大公司的题目真是考h.反正都已l用法实现?我就不多说了,大家看代码吧.代码里面注释我也量全写?一共有两个c?一个是Ant的模?一个是控制c?原代?大家可以在这取得:

http://www.aygfsteel.com/Files/itspy/baidu.rar



//////////////////////////////////////
/*癑ֺ面试?br /> * 有一?7厘米的细木杆Q在W?厘米?厘米?1厘米?7厘米?3厘米q五个位|上各有一只蚂蚁?br /> * 木杆很细Q不能同旉过一只蚂蚁。开?Ӟ蚂蚁的头朝左q是朝右是Q意的Q它们只会朝前走或调_
 * 但不会后退。当L两只蚂蚁头Ӟ两只蚂蚁会同时调头朝反方向走。假设蚂蚁们每秒钟可以走一厘米的距R?br /> * ~写E序Q求所有蚂蚁都d木杆 的最时间和最大时间?br /> *
 *
 * 分析:题目中的蚂蚁只可能相遇在整数?不可以相遇在其它?比如3.5cm处之cȝ,也就是可以让每只蚂蚁?1U?然后
 * 查看是否有相遇的卛_.
 *
 * q样我的E序实现思\是,初始?只蚂?让每只蚂蚁走1U?然后看是否有盔R?如果有则做相应处?当每只蚂蚁都
 * 走出木杆?我就记录当前旉.q样可以得到当前状态情况下,需要多久可以走出木?然后遍历所有状态则可以得到所?br /> * 可能.
 */

package baidu;

public class Ant {
 /*
  * step 表示蚂蚁每一个单位时间所走的长度
  */
 private final static int step = 1;

 /*
  * position表示蚂蚁所处的初始位置
  */
 private int position;

 /*
  * direction表示蚂蚁的前q方向,如果?表示?7厘米的方向走Q?如果为-1Q则表示往0的方向走?br />  */
 private int direction = 1;

 /*
  * 此函数运行一ơ,表示蚂蚁前进一个单位时_如果已经C木杆则会抛出异常
  */
 public void walk() {
  if (isOut()) {
   throw new RuntimeException("the ant is out");
  }
  position = position + this.direction * step;
 };


 /**
  * 查蚂蚁是否已l走出木杆,如果走出q回true
  *
  */

 public boolean isOut() {
  return position <= 0 || position >= 27;
 }

 /**
  * 查此蚂蚁是否已经遇到另外一只蚂?br />  * @param ant
  * @return 如果遇到q回true
  */
 public boolean isEncounter(Ant ant) {
  return ant.position == this.position;
 }

 /**
  * 改变蚂蚁的前q方?br />  */
 public void changeDistation() {
  direction = -1 * direction;
 }


 /**
  * 构造函?讄蚂蚁的初始前q方?和初始位|?br />  * @param position
  * @param direction
  */
 public Ant(int position, int direction) {
  this.position = position;
  if (direction != 1) {
   this.direction = -1;//方向讄初始位置,比如??也将其设|ؓ1.q样可以方便后面的处?br />  } else {
   this.direction = 1;
  }
 }

}

 

/////////////////////////////////////////////////////////


package baidu;

public class Controller {

 public static void main(String[] args) {

  int time = 0;
  for (int i = 0; i < 32; i++) {
   Ant[] antArray = getAntList(getPoistions(), getDirections(i));
   while (!isAllOut(antArray)) {
    for (Ant ant : antArray) {
     if (!ant.isOut()) {
      ant.walk();
     }
    }
    time++;
    // 查看是否有已l相遇的Ant,如果有则更改其前q方?br />    dealEncounter(antArray);
   }
   System.out.println(time);

   // 时间归0,q样可以重新讄条g,再次得到全部走完所需要的旉.
   time = 0;
  }

 }

 /**
  * q个函数的算法很乱,但暂时能解决问题
  *
  * @param list
  */
 public static void dealEncounter(Ant[] antArray) {

  int num_ant = antArray.length;
  for (int j = 0; j < num_ant; j++) {
   for (int k = j + 1; k < num_ant; k++) {
    if (antArray[j].isEncounter(antArray[k])) {
     antArray[j].changeDistation();
     antArray[k].changeDistation();
    }
   }
  }

 }

 /**
  * 因ؓ?只AntQ所以组合之后有32U组?刚好?位二q制来表C?如果?则表CAnt往0的方向走 如果?,则表C往27的方向走
  *
  * ?在通过Ant的构造函数设|初始值时,通过qo?修改成了-1.
  */
 public static int[] getDirections(int seed) {
  int result[] = new int[5];
  result[0] = seed % 2;
  result[1] = seed / 2 % 2;
  result[2] = seed / 4 % 2;
  result[3] = seed / 8 % 2;
  result[4] = seed / 16 % 2;

  System.out.println("directions is " + result[0] + "|" + result[1] + "|"
    + result[2] + "|" + result[3] + "|" + result[4]);

  return result;

 }

 /**
  * 扚w讄Ant的初始位|?q样讄不是十分必要,可以直接在代码中讄
  *
  * @return
  */
 public static int[] getPoistions() {
  return new int[] { 3, 7, 11, 17, 23 };
 }

 /**
  * 取得讄好初始值的5只Ant
  *
  * @param positions
  * @param directions
  * @return
  */
 public static Ant[] getAntList(int[] positions, int[] directions) {
  Ant ant3 = new Ant(positions[0], directions[0]);
  Ant ant7 = new Ant(positions[1], directions[1]);
  Ant ant11 = new Ant(positions[2], directions[2]);
  Ant ant17 = new Ant(positions[3], directions[3]);
  Ant ant23 = new Ant(positions[4], directions[4]);

  return new Ant[] { ant3, ant7, ant11, ant17, ant23 };
 }

 /**
  * 判断是否所有的Ant都已l走Z木杆,也就是设|退出条?br />  *
  * @param antArray
  * @return
  */
 public static boolean isAllOut(Ant[] antArray) {
  for (Ant ant : antArray) {
   if (ant.isOut() == false) {
    return false;
   }
  }
  return true;
 }
}

 



itspy 2006-11-10 16:46 发表评论
]]>
վ֩ģ壺 | | | | կ| | ӱʡ| ½| ˳| | | ɽ| ˴| Զ| | | ľ| | | | ʯ| | | | | ɽ| Ȫ| Ͼ| ˫| | ɽ| | | Т| Ƿ| | ˴| Ǹ| ɳƺ| Ԫ| |