锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
鍦ㄥ紑鍙戞暟鎹簱搴旂敤涓紝緇忓父浼氶亣鍒板鐞嗘椂闂寸殑闂錛屽鏌ヨ鎸囧畾鏃墮棿鐨勮褰曠瓑銆備笅闈㈠氨榪欎簺甯歌鐨勯棶棰橈紝緇撳悎鑷繁鐨勪竴浜涚粡楠岋紝鍜屽ぇ瀹舵帰璁ㄤ竴涓嬭繖綾婚棶棰樸?br />
棣栧厛浠嬬粛涓涓嬶紝SQL Server閲屽鐞嗘椂闂寸殑鍑犱釜涓昏鍑芥暟鐨勭敤娉曪細
getdate()鍑芥暟錛氬彇寰楃郴緇熷綋鍓嶇殑鏃ユ湡鍜屾椂闂淬傝繑鍥炲間負datetime綾誨瀷鐨勩傘
銆銆銆銆銆銆銆鐢ㄦ硶錛歡etdate()
銆銆銆銆銆銆銆渚嬪瓙錛?
銆銆銆銆銆銆銆select getdate() as dte,dateadd(day,-1,getdate()) as nowdat
銆銆銆銆銆銆銆杈撳嚭緇撴灉錛?
銆銆銆銆銆銆銆dte銆銆銆銆銆銆銆銆銆銆銆銆銆銆nowdat
銆銆銆銆銆銆銆---------------------------銆銆---------------------------
銆銆銆銆銆銆銆1999-11-21 19:13:10.083銆銆銆銆1999-11-20 19:13:10.083
銆銆
銆銆銆銆銆銆銆(1 row(s) affected)
銆銆銆銆銆銆銆
datepart()鍑芥暟錛氫互鏁存暟鐨勫艦寮忚繑鍥炴椂闂寸殑鎸囧畾閮ㄥ垎銆?
銆銆銆銆銆銆銆 鐢ㄦ硶錛歞atepart(datepart,date)
銆銆銆銆銆銆銆 鍙傛暟璇存槑錛歞atepart鏃惰榪斿洖鐨勬椂闂寸殑閮ㄥ垎錛屽父鐢ㄥ彇鍊紋ear銆乵onth銆乨ay銆乭our銆乵inute銆?br />
銆銆銆銆銆銆銆銆銆銆銆銆 date鏄墍鎸囧畾鐨勬椂闂淬?br />
銆銆銆銆銆銆銆 渚嬪瓙錛?br />
銆銆銆銆銆銆銆 SELECT DATEPART(month, GETDATE()) AS 'Month Number'
銆銆銆銆銆銆銆 杈撳嚭緇撴灉錛?br />
銆銆銆銆銆銆銆 Month Number
銆銆銆銆銆銆銆 ------------
銆銆銆銆銆銆銆 11
銆銆銆銆銆銆銆 (1 row(s) affected)
dateadd()鍑芥暟錛氶氳繃緇欐寚瀹氱殑鏃墮棿鐨勬寚瀹氶儴鍒嗗姞涓婁竴涓暣鏁板間互榪斿洖涓涓柊鏃墮棿鍊箋?br />
銆銆銆銆銆銆銆 鐢ㄦ硶錛歞ateadd(datepart,number,date)
銆銆銆銆銆銆銆 鍙傛暟璇存槑錛歞atepart(鍚屼笂錛?br />
銆銆銆銆銆銆銆銆銆銆銆銆 date(鍚屼笂)
銆銆銆銆銆銆銆銆銆銆銆銆 number瑕佸鍔犵殑鍊鹼紝鏁村瀷錛屽彲姝e彲璐燂紝姝e艱繑鍥瀌ate涔嬪悗鐨勬椂闂村鹼紝璐熷艱繑鍥瀌ate
銆銆銆銆銆銆銆銆銆銆銆銆 涔嬪墠鐨勬椂闂村?br />
銆銆銆銆銆銆銆 渚嬪瓙錛?br />
銆銆銆銆銆銆銆銆 select getdate() as today
銆銆銆銆銆銆銆銆 select dateadd(day,-1,getdate())
銆銆銆銆銆銆銆銆 select dateadd(day,1,getdate())
銆銆銆銆銆銆銆 杈撳嚭錛?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()鍑芥暟錛氳繑鍥炰袱涓椂闂翠互鎸囧畾鏃墮棿閮ㄥ垎鏉ヨ綆楃殑宸箋傝繑鍥炴暣鏁板箋傚1991-6-12鍜?991-6-21涔嬮棿浠ュぉ
銆銆銆銆銆銆銆銆鏉ョ畻鐩稿樊9澶?1998-6-12鍜?999-6-23鎸夊勾綆楃浉宸?騫達紝1999-12-1鍜?999-3-12鎸夋湀綆楃浉宸?涓湀
銆銆銆銆銆銆銆銆鐢ㄦ硶錛歞atediff(darepart,date1,date2)
銆銆銆銆銆銆銆銆鍙傛暟璇存槑錛歞atepart錛堝悓涓?
銆銆銆銆銆銆銆銆銆銆銆銆銆date1銆乨ate2(鍚屼笂date)
銆銆銆銆銆銆銆銆渚嬪瓙錛?br />
銆銆銆銆銆銆銆銆銆select datediff(month,'1991-6-12','1992-6-21') as a
銆銆銆銆銆銆銆銆杈撳嚭錛?br />
銆銆銆銆銆銆銆銆銆a銆銆銆銆銆
銆銆銆銆銆銆銆銆銆-----------
銆銆銆銆銆銆銆銆銆12
銆銆銆銆銆銆銆銆銆(1 row(s) affected)
]]>
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
闃呰鍏ㄦ枃
]]>
浣犲榪欎釜闂鍥版儜榪囧悧錛?
闃呰鍏ㄦ枃
]]>
緇忚繃鍒囨崲涓嶅悓鐨勫叧閿瓧錛屾垜鏈鍚庢壘鍒頒簡姝g‘鐨勯厤緗?nbsp; 闃呰鍏ㄦ枃
]]>
聽鏈変竴鏍?7鍘樼背鐨勭粏鏈ㄦ潌錛屽湪絎?鍘樼背銆?鍘樼背銆?1鍘樼背銆?7鍘樼背銆?3鍘樼背榪欎簲涓綅緗笂鍚勬湁涓鍙殏铓併?鏈ㄦ潌寰堢粏錛屼笉鑳藉悓鏃墮氳繃涓鍙殏铓併傚紑濮?鏃訛紝铓傝殎鐨勫ご鏈濆乏榪樻槸鏈濆彸鏄換鎰忕殑錛屽畠浠彧浼氭湞鍓嶈蛋鎴栬皟澶達紝 浣嗕笉浼氬悗閫銆傚綋浠繪剰涓ゅ彧铓傝殎紕板ご鏃訛紝涓ゅ彧铓傝殎浼氬悓鏃惰皟澶存湞鍙嶆柟鍚戣蛋銆傚亣璁捐殏铓佷滑姣忕閽熷彲浠ヨ蛋涓鍘樼背鐨勮窛紱匯?緙栧啓紼嬪簭錛屾眰鎵鏈夎殏铓侀兘紱誨紑鏈ㄦ潌 鐨勬渶灝忔椂闂村拰鏈澶ф椂闂淬?/p>
鐪嬩簡榪欎釜棰樼洰涔嬪悗,紿佺劧寰堟劅鍏磋叮,浠婂ぉ鎼炰簡鍗婂ぉ鎶婂畠鍋氬嚭鏉ヤ簡,澶ф鑺變簡1涓崐灝忔椂.澶у叕鍙哥殑棰樼洰鐪熸槸鑰冧漢.鍙嶆閮藉凡緇忕敤綆楁硶瀹炵幇浜?鎴戝氨涓嶅璇翠簡,澶у鐪嬩唬鐮佸惂.浠g爜閲岄潰娉ㄩ噴鎴戜篃灝介噺鍏ㄥ啓浜?涓鍏辨湁涓や釜綾?涓涓槸Ant鐨勬ā鍨?涓涓槸鎺у埗綾?鍘熶唬鐮?澶у鍙互鍦ㄨ繖鍙栧緱:
http://www.tkk7.com/Files/itspy/baidu.rar
//////////////////////////////////////
/*鐧懼害闈㈣瘯棰?br />聽* 鏈変竴鏍?7鍘樼背鐨勭粏鏈ㄦ潌錛屽湪絎?鍘樼背銆?鍘樼背銆?1鍘樼背銆?7鍘樼背銆?3鍘樼背榪欎簲涓綅緗笂鍚勬湁涓鍙殏铓併?br />聽* 鏈ㄦ潌寰堢粏錛屼笉鑳藉悓鏃墮氳繃涓鍙殏铓併傚紑濮?鏃訛紝铓傝殎鐨勫ご鏈濆乏榪樻槸鏈濆彸鏄換鎰忕殑錛屽畠浠彧浼氭湞鍓嶈蛋鎴栬皟澶達紝
聽* 浣嗕笉浼氬悗閫銆傚綋浠繪剰涓ゅ彧铓傝殎紕板ご鏃訛紝涓ゅ彧铓傝殎浼氬悓鏃惰皟澶存湞鍙嶆柟鍚戣蛋銆傚亣璁捐殏铓佷滑姣忕閽熷彲浠ヨ蛋涓鍘樼背鐨勮窛紱匯?br />聽* 緙栧啓紼嬪簭錛屾眰鎵鏈夎殏铓侀兘紱誨紑鏈ㄦ潌 鐨勬渶灝忔椂闂村拰鏈澶ф椂闂淬?br />聽*
聽*
聽* 鍒嗘瀽:棰樼洰涓殑铓傝殎鍙彲鑳界浉閬囧湪鏁存暟鐐?涓嶅彲浠ョ浉閬囧湪鍏跺畠鐐?姣斿3.5cm澶勪箣綾葷殑,涔熷氨鏄彲浠ヨ姣忓彧铓傝殎璧?1縐?鐒跺悗
聽* 鏌ョ湅鏄惁鏈夌浉閬囩殑鍗沖彲.
聽*
聽* 榪欐牱鎴戠殑紼嬪簭瀹炵幇鎬濊礬灝辨槸,鍒濆鍖?鍙殏铓?璁╂瘡鍙殏铓佽蛋1縐?鐒跺悗鐪嬫槸鍚︽湁鐩擱亣鐨?濡傛灉鏈夊垯鍋氱浉搴斿鐞?褰撴瘡鍙殏铓侀兘
聽* 璧板嚭鏈ㄦ潌鏃?鎴戝氨璁板綍褰撳墠鏃墮棿.榪欐牱灝卞彲浠ュ緱鍒板綋鍓嶇姸鎬佹儏鍐典笅,闇瑕佸涔呭彲浠ヨ蛋鍑烘湪鏉?鐒跺悗閬嶅巻鎵鏈夌姸鎬佸垯鍙互寰楀埌鎵鑳?br />聽* 鍙兘.
聽*/
package baidu;
public class Ant {
聽/*
聽 * step 琛ㄧず铓傝殎姣忎竴涓崟浣嶆椂闂存墍璧扮殑闀垮害
聽 */
聽private final static int step = 1;
聽/*
聽 * position琛ㄧず铓傝殎鎵澶勭殑鍒濆浣嶇疆
聽 */
聽private int position;
聽/*
聽 * direction琛ㄧず铓傝殎鐨勫墠榪涙柟鍚戯紝濡傛灉涓?琛ㄧず鍚?7鍘樼背鐨勬柟鍚戣蛋錛?濡傛灉涓猴紞1錛屽垯琛ㄧず寰0鐨勬柟鍚戣蛋銆?br />聽 */
聽private int direction = 1;
聽/*
聽 * 姝ゅ嚱鏁拌繍琛屼竴嬈★紝琛ㄧず铓傝殎鍓嶈繘涓涓崟浣嶆椂闂達紝濡傛灉宸茬粡璧頒笅鏈ㄦ潌鍒欎細鎶涘嚭寮傚父
聽 */
聽public void walk() {
聽聽if (isOut()) {
聽聽聽throw new RuntimeException("the ant is out");
聽聽}
聽聽position = position + this.direction * step;
聽};
聽/**
聽 * 媯鏌ヨ殏铓佹槸鍚﹀凡緇忚蛋鍑烘湪鏉嗭紝濡傛灉璧板嚭榪斿洖true
聽 *
聽 */
聽public boolean isOut() {
聽聽return position <= 0 || position >= 27;
聽}
聽/**
聽 * 媯鏌ユ铓傝殎鏄惁宸茬粡閬囧埌鍙﹀涓鍙殏铓?br />聽 * @param ant
聽 * @return 濡傛灉閬囧埌榪斿洖true
聽 */
聽public boolean isEncounter(Ant ant) {
聽聽return ant.position == this.position;
聽}
聽/**
聽 * 鏀瑰彉铓傝殎鐨勫墠榪涙柟鍚?br />聽 */
聽public void changeDistation() {
聽聽direction = -1 * direction;
聽}
聽/**
聽 * 鏋勯犲嚱鏁?璁劇疆铓傝殎鐨勫垵濮嬪墠榪涙柟鍚?鍜屽垵濮嬩綅緗?br />聽 * @param position
聽 * @param direction
聽 */
聽public Ant(int position, int direction) {
聽聽this.position = position;
聽聽if (direction != 1) {
聽聽聽this.direction = -1;//鏂瑰悜璁劇疆鍒濆浣嶇疆,姣斿涓?鏃?涔熷皢鍏惰緗負1.榪欐牱鍙互鏂逛究鍚庨潰鐨勫鐞?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++;
聽聽聽聽// 鏌ョ湅鏄惁鏈夊凡緇忕浉閬囩殑Ant,濡傛灉鏈夊垯鏇存敼鍏跺墠榪涙柟鍚?br />聽聽聽聽dealEncounter(antArray);
聽聽聽}
聽聽聽System.out.println(time);
聽聽聽// 灝嗘椂闂村綊0,榪欐牱鍙互閲嶆柊璁劇疆鏉′歡,鍐嶆寰楀埌鍏ㄩ儴璧板畬鎵闇瑕佺殑鏃墮棿.
聽聽聽time = 0;
聽聽}
聽}
聽/**
聽 * 榪欎釜鍑芥暟鐨勭畻娉曞緢涔憋紝浣嗘殏鏃惰兘瑙e喅闂
聽 *
聽 * @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();
聽聽聽聽}
聽聽聽}
聽聽}
聽}
聽/**
聽 * 鍥犱負鏈?鍙狝nt錛屾墍浠ョ粍鍚堜箣鍚庢湁32縐嶇粍鍚?鍒氬ソ鐢?浣嶄簩榪涘埗鏉ヨ〃紺?濡傛灉涓?鍒欒〃紺篈nt寰0鐨勬柟鍚戣蛋 濡傛灉涓?,鍒欒〃紺哄線27鐨勬柟鍚戣蛋
聽 *
聽 * 娉?鍦ㄩ氳繃Ant鐨勬瀯閫犲嚱鏁拌緗垵濮嬪兼椂,閫氳繃榪囨護鎶?淇敼鎴愪簡-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;
聽}
聽/**
聽 * 鎵歸噺璁劇疆Ant鐨勫垵濮嬩綅緗?榪欐牱璁劇疆涓嶆槸鍗佸垎蹇呰,鍙互鐩存帴鍦ㄤ唬鐮佷腑璁劇疆
聽 *
聽 * @return
聽 */
聽public static int[] getPoistions() {
聽聽return new int[] { 3, 7, 11, 17, 23 };
聽}
聽/**
聽 * 鍙栧緱璁劇疆濂藉垵濮嬪肩殑5鍙狝nt
聽 *
聽 * @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閮藉凡緇忚蛋鍑轟簡鏈ㄦ潌,涔熷氨鏄緗鍑烘潯浠?br />聽 *
聽 * @param antArray
聽 * @return
聽 */
聽public static boolean isAllOut(Ant[] antArray) {
聽聽for (Ant ant : antArray) {
聽聽聽if (ant.isOut() == false) {
聽聽聽聽return false;
聽聽聽}
聽聽}
聽聽return true;
聽}
}
聽