锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久成人精品视频,999久久久国产精品,无夜精品久久久久久http://www.shnenglu.com/luyulaile/category/11056.htmlI canzh-cnTue, 22 Feb 2011 10:06:36 GMTTue, 22 Feb 2011 10:06:36 GMT60Java涓嶤++鐨勫尯鍒?/title><link>http://www.shnenglu.com/luyulaile/archive/2011/02/14/140003.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Sun, 13 Feb 2011 17:32:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2011/02/14/140003.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/140003.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2011/02/14/140003.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/140003.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/140003.html</trackback:ping><description><![CDATA[<p>(1)鎸囬拡鍜屽紩鐢ㄧ殑闂<br>java涓病鏈夋寚閽堬紝浣嗘槸鏁扮粍鍚嶏紝瀵硅薄鍚嶉兘鏄叾寮曠敤錛?br>鎸囬拡榪樻湁甯擱噺鎸囬拡錛屾瘮濡傛暟緇勫悕<br>(2)new鐨勫尯鍒?br>java涓殑new榪斿洖瀵硅薄鐨勫簲鐢?br>c++涓殑new榪斿洖鍏舵寚閽堬紝<br>濡傛灉c++涓?br>SparseMatrix s=SparseMatrix(4,4,6,arrays);<br>濡傛灉java涓?br>SparseMatrix s=new SparseMatrix(4,4,6,arrays);<br><br></p> <img src ="http://www.shnenglu.com/luyulaile/aggbug/140003.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2011-02-14 01:32 <a href="http://www.shnenglu.com/luyulaile/archive/2011/02/14/140003.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍐呭瓨鍒掑垎錛屽爢鏍堝尯鍒?/title><link>http://www.shnenglu.com/luyulaile/archive/2011/02/14/140002.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Sun, 13 Feb 2011 17:14:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2011/02/14/140002.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/140002.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2011/02/14/140002.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/140002.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/140002.html</trackback:ping><description><![CDATA[<p>鍘熸枃鍦板潃<a >http://www.ksarea.com/articles/20070829_memory-partition-stack-heap-difference.html</a><br><br>涓鐩村鍐呭瓨鍖哄煙鐨勫垝鍒嗭紝紼嬪簭鍙橀噺鐨勫唴瀛樺垎閰嶉棶棰樻ā緋婁笉娓呫傝繘琛屽鏂瑰弬鑰冩葷粨濡備笅銆?/p> <p>涓銆佷竴涓粡榪囩紪璇戠殑C/C++鐨勭▼搴忓崰鐢ㄧ殑鍐呭瓨鍒嗘垚浠ヤ笅鍑犱釜閮ㄥ垎錛?br>1銆佹爤鍖猴紙stack錛夛細鐢辯紪璇戝櫒鑷姩鍒嗛厤鍜岄噴鏀?nbsp;錛屽瓨鏀懼嚱鏁扮殑鍙傛暟鍊箋佸眬閮ㄥ彉閲忕殑鍊肩瓑錛岀敋鑷沖嚱鏁扮殑璋冪敤榪囩▼閮芥槸鐢ㄦ爤鏉ュ畬鎴愩傚叾鎿嶄綔鏂瑰紡綾諱技浜庢暟鎹粨鏋勪腑鐨勬爤銆?br>2銆佸爢鍖猴紙heap錛?nbsp;錛氫竴鑸敱紼嬪簭鍛樻墜鍔ㄧ敵璇蜂互鍙婇噴鏀撅紝 鑻ョ▼搴忓憳涓嶉噴鏀撅紝紼嬪簭緇撴潫鏃跺彲鑳界敱OS鍥炴敹 銆傛敞鎰忓畠涓庢暟鎹粨鏋勪腑鐨勫爢鏄袱鍥炰簨錛屽垎閰嶆柟寮忕被浼間簬閾捐〃銆?br>3銆佸叏灞鍖猴紙闈欐佸尯錛夛紙static錛夛細鍏ㄥ眬鍙橀噺鍜岄潤鎬佸彉閲忕殑瀛樺偍鏄斁鍦ㄤ竴鍧楃殑錛屽垵濮嬪寲鐨勫叏灞鍙橀噺鍜岄潤鎬佸彉閲忓湪涓鍧楀尯鍩燂紝 鏈垵濮嬪寲鐨勫叏灞鍙橀噺鍜屾湭鍒濆鍖栫殑闈欐佸彉閲忓湪鐩擱偦鐨勫彟涓鍧楀尯鍩熴傜▼搴忕粨鏉熷悗鐢辯郴緇熼噴鏀劇┖闂淬?nbsp;<br>4銆佹枃瀛楀父閲忓尯錛氬父閲忓瓧絎︿覆灝辨槸鏀懼湪榪欓噷鐨勩?nbsp;紼嬪簭緇撴潫鍚庣敱緋葷粺閲婃斁絀洪棿銆?br>5銆佺▼搴忎唬鐮佸尯錛氬瓨鏀懼嚱鏁頒綋鐨勪簩榪涘埗浠g爜銆?/p> <p>涓嬮潰鐨勪緥瀛愬彲浠ュ畬鍏ㄥ睍紺轟笉鍚岀殑鍙橀噺鎵鍗犵殑鍐呭瓨鍖哄煙錛?br><coolcode lang=cpp linenum="off"><br>//main.cpp<br>int a = 0; 鍏ㄥ眬鍒濆鍖栧尯<br>char *p1; 鍏ㄥ眬鏈垵濮嬪寲鍖?br>main()<br>{<br>int b; //鏍堜腑<br>char s[] = “abc”; //鏍堜腑<br>char *p2; //鏍堜腑<br>char *p3 = “123456″; //123456\0鍦ㄥ父閲忓尯錛宲3鍦ㄦ爤涓?br>static int c =0錛?//鍏ㄥ眬錛堥潤鎬侊級鍒濆鍖栧尯<br>//浠ヤ笅鍒嗛厤寰楀埌鐨?0鍜?0瀛楄妭鐨勫尯鍩熷氨鍦ㄥ爢鍖?br>p1 = (char *)malloc(10);<br>p2 = (char *)malloc(20);<br>strcpy(p1, “123456″); //123456\0鏀懼湪甯擱噺鍖猴紝緙栬瘧鍣ㄥ彲鑳戒細灝嗗畠涓巔3鎵鎸囧悜鐨?#8221;123456″浼樺寲鎴愪竴涓湴鏂廣?br>} </coolcode><br><span id=more-124></span><br>浜屻佹爤錛坰tack錛夊拰鍫嗭紙heap錛夊叿浣撶殑鍖哄埆銆?br>1銆佸湪鐢寵鏂瑰紡涓?br>鏍堬紙stack錛? 鐜板湪寰堝浜洪兘縐頒箣涓哄爢鏍堬紝榪欎釜鏃跺欏疄闄呬笂榪樻槸鎸囩殑鏍堛傚畠鐢辯紪璇戝櫒鑷姩綆$悊錛屾棤闇鎴戜滑鎵嬪伐鎺у埗銆?渚嬪錛屽0鏄庡嚱鏁頒腑鐨勪竴涓眬閮ㄥ彉閲?int b 緋葷粺鑷姩鍦ㄦ爤涓負b寮杈熺┖闂達紱鍦ㄨ皟鐢ㄤ竴涓嚱鏁版椂錛岀郴緇熻嚜鍔ㄧ殑緇欏嚱鏁扮殑褰㈠弬鍙橀噺鍦ㄦ爤涓紑杈熺┖闂淬?br>鍫嗭紙heap錛? 鐢寵鍜岄噴鏀劇敱紼嬪簭鍛樻帶鍒訛紝騫舵寚鏄庡ぇ灝忋傚鏄撲駭鐢焟emory leak銆?br>鍦–涓嬌鐢╩alloc鍑芥暟銆?br>濡傦細p1 = (char *)malloc(10);<br>鍦–++涓敤new榪愮畻絎︺?br>濡傦細p2 = (char *)malloc(10);<br>浣嗘槸娉ㄦ剰p1鏈韓鍦ㄥ叏灞鍖猴紝鑰宲2鏈韓鏄湪鏍堜腑鐨勶紝鍙槸瀹冧滑鎸囧悜鐨勭┖闂存槸鍦ㄥ爢涓?/p> <p>2銆佺敵璇峰悗緋葷粺鐨勫搷搴斾笂<br>鏍堬紙stack錛?鍙鏍堢殑鍓╀綑絀洪棿澶т簬鎵鐢寵絀洪棿錛岀郴緇熷皢涓虹▼搴忔彁渚涘唴瀛橈紝鍚﹀垯灝嗘姤寮傚父鎻愮ず鏍堟孩鍑恒?br>鍫嗭紙heap錛? 棣栧厛搴旇鐭ラ亾鎿嶄綔緋葷粺鏈変竴涓褰曠┖闂插唴瀛樺湴鍧鐨勯摼琛紝褰撶郴緇熸敹鍒扮▼搴忕殑鐢寵鏃訛紝 浼氶亶鍘嗚閾捐〃錛屽鎵劇涓涓┖闂村ぇ浜庢墍鐢寵絀洪棿鐨勫爢緇撶偣錛岀劧鍚庡皢璇ョ粨鐐逛粠絀洪棽緇撶偣閾捐〃涓垹闄わ紝騫跺皢璇ョ粨鐐圭殑絀洪棿鍒嗛厤緇欑▼搴忋傚彟澶栵紝瀵逛簬澶у鏁扮郴緇燂紝浼氬湪榪欏潡鍐呭瓨絀洪棿涓殑棣栧湴鍧澶勮褰曟湰嬈″垎閰嶇殑澶у皬錛岃繖鏍鳳紝浠g爜涓殑delete鎴杅ree璇彞鎵嶈兘姝g‘鐨勯噴鏀炬湰鍐呭瓨絀洪棿銆傚彟澶栵紝鐢變簬鎵懼埌鐨勫爢緇撶偣鐨勫ぇ灝忎笉涓瀹氭濂界瓑浜庣敵璇風殑澶у皬錛岀郴緇熶細鑷姩鐨勫皢澶氫綑鐨勯偅閮ㄥ垎閲嶆柊鏀懼叆絀洪棽閾捐〃涓?/p> <p>3銆佺敵璇峰ぇ灝忕殑闄愬埗<br>鏍堬紙stack錛?鍦╓indows涓?鏍堟槸鍚戜綆鍦板潃鎵╁睍鐨勬暟鎹粨鏋勶紝鏄竴鍧楄繛緇殑鍐呭瓨鐨勫尯鍩熴傝繖鍙ヨ瘽鐨勬剰鎬濇槸鏍堥《鐨勫湴鍧鍜屾爤鐨勬渶澶у閲忔槸緋葷粺棰勫厛瑙勫畾濂界殑錛屽湪WINDOWS涓嬶紝鏍堢殑澶у皬鏄?M錛堜篃鏈夌殑璇存槸1M錛屾諱箣鏄竴涓紪璇戞椂灝辯‘瀹氱殑甯告暟錛夛紝濡傛灉鐢寵鐨勭┖闂磋秴榪囨爤鐨勫墿浣欑┖闂存椂錛屽皢鎻愮ずoverflow銆傚洜姝わ紝鑳戒粠鏍堣幏寰楃殑絀洪棿杈冨皬銆?渚嬪錛屽湪VC6涓嬮潰錛岄粯璁ょ殑鏍堢┖闂村ぇ灝忔槸1M錛堝ソ鍍忔槸錛岃涓嶆竻妤氫簡錛夈傚綋鐒訛紝鎴戜滑鍙互淇敼錛氭墦寮宸ョ▼錛屼緷嬈℃搷浣滆彍鍗曞涓嬶細Project->Setting->Link錛屽湪Category 涓変腑Output錛岀劧鍚庡湪Reserve涓瀹氬爢鏍堢殑鏈澶у煎拰commit銆?br><strong>娉ㄦ剰</strong>錛歳eserve鏈灝忓間負4Byte錛沜ommit鏄繚鐣欏湪铏氭嫙鍐呭瓨鐨勯〉鏂囦歡閲岄潰錛屽畠璁劇疆鐨勮緝澶т細浣挎爤寮杈熻緝澶х殑鍊鹼紝鍙兘澧炲姞鍐呭瓨鐨勫紑閿鍜屽惎鍔ㄦ椂闂淬?/p> <p>鍫嗭紙heap錛? 鍫嗘槸鍚戦珮鍦板潃鎵╁睍鐨勬暟鎹粨鏋勶紝鏄笉榪炵畫鐨勫唴瀛樺尯鍩燂紙絀洪棽閮ㄥ垎鐢ㄩ摼琛ㄤ覆鑱旇搗鏉ワ級銆傛鏄敱浜庣郴緇熸槸鐢ㄩ摼琛ㄦ潵瀛樺偍絀洪棽鍐呭瓨錛岃嚜鐒舵槸涓嶈繛緇殑錛岃岄摼琛ㄧ殑閬嶅巻鏂瑰悜鏄敱浣庡湴鍧鍚戦珮鍦板潃銆備竴鑸潵璁插湪32浣嶇郴緇熶笅錛屽爢鍐呭瓨鍙互杈懼埌4G鐨勭┖闂達紝浠庤繖涓搴︽潵鐪嬪爢鍐呭瓨鍑犱箮鏄病鏈変粈涔堥檺鍒剁殑銆傜敱姝ゅ彲瑙侊紝鍫嗚幏寰楃殑絀洪棿姣旇緝鐏墊椿錛屼篃姣旇緝澶с?/p> <p>4銆佸垎閰嶇┖闂寸殑鏁堢巼涓?br>鏍堬紙stack錛?鏍堟槸鏈哄櫒緋葷粺鎻愪緵鐨勬暟鎹粨鏋勶紝璁$畻鏈轟細鍦ㄥ簳灞傚鏍堟彁渚涙敮鎸侊細鍒嗛厤涓撻棬鐨勫瘎瀛樺櫒瀛樻斁鏍堢殑鍦板潃錛屽帇鏍堝嚭鏍堥兘鏈変笓闂ㄧ殑鎸囦護鎵ц錛岃繖灝卞喅瀹氫簡鏍堢殑鏁堢巼姣旇緝楂樸備絾紼嬪簭鍛樻棤娉曞鍏惰繘琛屾帶鍒躲?br>鍫嗭紙heap錛?鏄疌/C++鍑芥暟搴撴彁渚涚殑錛岀敱new鎴杕alloc鍒嗛厤鐨勫唴瀛橈紝涓鑸熷害姣旇緝鎱紝鑰屼笖瀹規槗浜х敓鍐呭瓨紕庣墖銆傚畠鐨勬満鍒舵槸寰堝鏉傜殑錛屼緥濡備負浜嗗垎閰嶄竴鍧楀唴瀛橈紝搴撳嚱鏁頒細鎸夌収涓瀹氱殑綆楁硶錛堝叿浣撶殑綆楁硶鍙互鍙傝冩暟鎹粨鏋?鎿嶄綔緋葷粺錛夊湪鍫嗗唴瀛樹腑鎼滅儲鍙敤鐨勮凍澶熷ぇ灝忕殑絀洪棿錛屽鏋滄病鏈夎凍澶熷ぇ灝忕殑絀洪棿錛堝彲鑳芥槸鐢變簬鍐呭瓨紕庣墖澶錛夛紝灝辨湁鍙兘璋冪敤緋葷粺鍔熻兘鍘誨鍔犵▼搴忔暟鎹鐨勫唴瀛樼┖闂達紝榪欐牱灝辨湁鏈轟細鍒嗗埌瓚沖澶у皬鐨勫唴瀛橈紝鐒跺悗榪涜榪斿洖銆傝繖鏍峰彲鑳藉紩鍙戠敤鎴鋒佸拰鏍稿績鎬佺殑鍒囨崲錛屽唴瀛樼殑鐢寵錛屼唬浠峰彉寰楁洿鍔犳槀璐點傛樉鐒訛紝鍫嗙殑鏁堢巼姣旀爤瑕佷綆寰楀銆?/p> <p>5銆佸爢鍜屾爤涓殑瀛樺偍鍐呭<br>鏍堬紙stack錛?鍦ㄥ嚱鏁拌皟鐢ㄦ椂錛岀涓涓繘鏍堢殑鏄富鍑芥暟涓瓙鍑芥暟璋冪敤鍚庣殑涓嬩竴鏉℃寚浠わ紙瀛愬嚱鏁拌皟鐢ㄨ鍙ョ殑涓嬩竴鏉″彲鎵ц璇彞錛夌殑鍦板潃錛岀劧鍚庢槸瀛愬嚱鏁扮殑鍚勪釜褰㈠弬銆傚湪澶у鏁扮殑C緙栬瘧鍣ㄤ腑錛屽弬鏁版槸鐢卞彸寰宸﹀叆鏍堢殑錛岀劧鍚庢槸瀛愬嚱鏁頒腑鐨勫眬閮ㄥ彉閲忋傛敞鎰忥細闈欐佸彉閲忔槸涓嶅叆鏍堢殑銆?褰撴湰嬈″嚱鏁拌皟鐢ㄧ粨鏉熷悗錛屽眬閮ㄥ彉閲忓厛鍑烘爤錛岀劧鍚庢槸鍙傛暟錛屾渶鍚庢爤欏舵寚閽堟寚鍚戞渶寮濮嬪瓨鐨勫湴鍧錛屼篃灝辨槸涓誨嚱鏁頒腑瀛愬嚱鏁拌皟鐢ㄥ畬鎴愮殑涓嬩竴鏉℃寚浠わ紝紼嬪簭鐢辮鐐圭戶緇繍琛屻?br>鍫嗭紙heap錛?涓鑸槸鍦ㄥ爢鐨勫ご閮ㄧ敤涓涓瓧鑺傚瓨鏀懼爢鐨勫ぇ灝忥紝鍫嗕腑鐨勫叿浣撳唴瀹規湁紼嬪簭鍛樺畨鎺掋?/p> <p>6銆佸瓨鍙栨晥鐜囩殑姣旇緝<br>榪欎釜搴旇鏄樉鑰屾槗瑙佺殑銆傛嬁鏍堜笂鐨勬暟緇勫拰鍫嗕笂鐨勬暟緇勬潵璇達細<br><coolcode lang=cpp linenum="off"><br>void main()<br>{<br>int arr[5]={1,2,3,4,5};<br>int *arr1;<br>arr1=new int[5];<br>for (int j=0;j<=4;j++)<br>{<br>arr1[j]=j+6;<br>}<br>int a=arr[1];<br>int b=arr1[1];<br>}<br></coolcode><br>涓婇潰浠g爜涓紝arr1錛堝眬閮ㄥ彉閲忥級鏄湪鏍堜腑錛屼絾鏄寚鍚戠殑絀洪棿紜湪鍫嗕笂錛屼袱鑰呯殑瀛樺彇鏁堢巼錛屽綋鐒舵槸arr楂樸傚洜涓篴rr[1]鍙互鐩存帴璁塊棶錛屼絾鏄闂產rr1[1]錛岄鍏堣璁塊棶鏁扮粍鐨勮搗濮嬪湴鍧arr1錛岀劧鍚庢墠鑳借闂埌arr1[1]銆?/p> <p>鎬昏岃█涔嬶紝璦鑰屾諱箣錛?br>鍫嗗拰鏍堢殑鍖哄埆鍙互鐢ㄥ涓嬬殑姣斿柣鏉ョ湅鍑猴細<br>浣跨敤鏍堝氨璞℃垜浠幓楗閲屽悆楗紝鍙鐐硅彍錛堝0鏄庡彉閲忥級銆佷粯閽便佸拰鍚冿紙浣跨敤錛夛紝鍚冮ケ浜嗗氨璧幫紝涓嶅繀鐞嗕細鍒囪彍銆佹礂鑿滅瓑鍑嗗宸ヤ綔鍜屾礂紕椼佸埛閿呯瓑鎵熬宸ヤ綔錛屼粬鐨勫ソ澶勬槸蹇嵎錛屼絾鏄嚜鐢卞害灝忋?br>浣跨敤鍫嗗氨璞℃槸鑷繁鍔ㄦ墜鍋氬枩嬈㈠悆鐨勮彍鑲達紝姣旇緝楹葷儲錛屼絾鏄瘮杈冪鍚堣嚜宸辯殑鍙e懗錛岃屼笖鑷敱搴﹀ぇ</p> <img src ="http://www.shnenglu.com/luyulaile/aggbug/140002.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2011-02-14 01:14 <a href="http://www.shnenglu.com/luyulaile/archive/2011/02/14/140002.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C++瀵硅薄鏁扮粍浣滀負綾繪垚鍛樼殑闂http://www.shnenglu.com/luyulaile/archive/2011/02/14/140001.htmlluisluisSun, 13 Feb 2011 17:08:00 GMThttp://www.shnenglu.com/luyulaile/archive/2011/02/14/140001.htmlhttp://www.shnenglu.com/luyulaile/comments/140001.htmlhttp://www.shnenglu.com/luyulaile/archive/2011/02/14/140001.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/140001.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/140001.htmlclass ObjectB{};

class ObjectA{
public:
    ObjectB array[5];//瀵硅薄鏁扮粍浣滀負綾葷殑鎴愬憳
}

閭f牱鐨勮瘽瀵硅薄鏁扮粍鐨勫垵濮嬪寲浼氬彉寰楀緢楹葷儲錛?br>鍥犱負鏁扮粍鍚嶄笉鑳戒綔涓哄乏鍊鹼紝鎵浠ヤ笉鍙互鎸囬拡浼犻掔殑鏂瑰紡璧嬪箋?br>鑰屼笖涓嶈兘閫氳繃鍙傛暟鍒楄〃錛堟瀯閫犲嚱鏁板悗闈㈠姞涓涓啋鍙鳳級鐨勬柟寮忓垵濮嬪寲錛?br>鎵浠ュ彧鑳借綾籓bjectA鑷姩璋冪敤綾籓bjectB鐨勬棤鍙傛瀯閫犲嚱鏁?
---------------
#include <iostream.h>
#include 
"stdlib.h"
class   ObjectB{
public:
    
int a;
public:
    ObjectB(
int m=0)
    
{
        a
=m;
    }

}
;
class   ObjectA
public:
        ObjectB   Array[
5]; 
public
        ObjectA(
int   *p)
        
{
            Array[
0]=ObjectB(p[0]);
            Array[
1]=ObjectB(p[1]);
            Array[
2]=ObjectB(p[2]);
        }
 
}
;

int main()
{
    
int p[5]={0,2,2,3,4};
    ObjectA am
=ObjectA(p);
    cout
<<am.Array[1].a<<endl;
    
return 0;
}

---------------

鎴戜滑鍙互浣跨敤鏇夸唬鏂瑰紡錛?br>class A{};

classB{
public:
    A*a;//A綾誨瀷鐨勬寚閽堜綔涓虹被鐨勬垚鍛?br>}
鍚屾牱甯︽潵寰堝ぇ鐨勯棶棰橈紝
錛?錛夋祬鎷瘋礉錛屾繁鎷瘋礉鐨勯棶棰橈紝闄ら潪閲嶈澆鎷瘋礉鏋勯犲嚱鏁幫紝綾籅鎵嶈兘瀹炵幇娣辨嫹璐濓紝鍥犱負鎴愬憳涓湁鎸囬拡錛屾墍浠ユ棤娉曠畝鍗曠殑鐢ㄦ嫹璐濇瀯閫犲嚱鏁扮敓鎴愪竴涓柊瀵硅薄錛岃岀敤鏃犲弬鏋勯犲嚱鏁扮敓鎴愮殑鏂板璞′篃浼氭湁闂錛屽洜涓洪噷闈㈢殑鎸囬拡涓鑸兘榛樿涓篘ULL浜嗐?br>
閲嶈澆鎷瘋礉鏋勯犲嚱鏁扮殑鏃跺欓渶瑕佺敵璇蜂竴瀹氶暱搴︾殑鍐呭瓨錛屽皢鎷瘋礉瀵硅薄鐨勬寚閽堟墍鎸囧悜鐨勭┖闂存嫹璐濆埌鏂扮敵璇風殑絀洪棿錛屽啀榪涜鎿嶄綔銆傛敞鎰忕敵璇峰悗瑕侀噴鏀俱?br>涓涓嫹璐濇瀯閫犲嚱鏁扮殑渚嬪瓙
SparseMatrix::SparseMatrix(const SparseMatrix&s)
    
{
      Rows
=s.Rows;
   Cols
=s.Cols;
   Count
=s.Count;
   smArray
=new Trituple[6];
//姝ゅ榪橀渶瑕佸鍒跺璞?/span>
    }


----------------------
琛ュ厖鐭ヨ瘑錛?br>------------------http://www.ksarea.com/articles/20070829_memory-partition-stack-heap-difference.html

C/C++搴旇鏄ぇ瀛﹂噷鏈鍏堟帴瑙︾殑緙栫▼璇█錛屽畠浠殑閲嶈鎬т笉璦鑰屽柣銆備絾鏄垜濮嬬粓鎶辯潃“鏁扮粍鍚嶅氨鏄寚閽?#8221;鐨勯敊璇俊鏉″埌鐜板湪錛屽彲鑳芥槸鍥犱負澶у鑰佸笀閿欒鐨勮瑙d嬌鎴戜竴鐩翠繚鐣欑潃榪欑璇В銆傛寚閽堟槸C/C++璇█鐨勭壒鑹詫紝鑰屾暟緇勫悕涓庢寚閽堟湁澶鐨勭浉浼鹼紝鐢氳嚦寰堝鏃跺欙紝鏁扮粍鍚嶅彲浠ヤ綔涓烘寚閽堜嬌鐢紝鎵浠ヤ篃闅懼厤鍦ㄥ涔犱腑灝嗕袱鑰呮販娣嗐傝繖閲屼粙緇嶄笅鎸囬拡鍜屾暟緇勫悕鐨勫尯鍒?

1.鎸囬拡鍜屾暟緇勫悕鍗犳嵁鐨勫唴瀛樼┖闂村ぇ灝忎笉涓鏍鳳紝濡備笅紼嬪簭1錛?br>
char str[10];
char *pstr=str;
cout<<
cout<<sizeof

絎竴琛岃緭鍑虹粨鏋滄槸錛?0錛岀浜岃杈撳嚭緇撴灉鏄細4

浠庤繖閲屾垜浠彲浠ョ湅鍑猴細鏁扮粍鍚嶅搴旂潃錛堣屼笉鏄寚鍚戯級涓鍧楀唴瀛橈紙鏁扮粍鎵鍗犵殑鍐呭瓨鍖哄煙錛夋垨鑰呰鏄寚浠f暟緇勮繖縐嶆暟鎹粨鏋勶紝鍏跺湴鍧涓庡閲忓湪鐢熷懡鏈熷唴淇濇寔涓嶅彉錛屽彧鏈夋暟緇勭殑鍐呭鍙互鏀瑰彉銆傛寚閽堝搴旂潃涓涓崰鎹?涓瓧鑺傦紙Win32錛夌殑鍐呭瓨鍖哄煙錛岃屾寚鍚戣繖4涓瓧鑺傛墍瀛樺偍鐨勫湴鍧鎵瀵瑰簲鐨勫唴瀛樺崟鍏冿紝瀹冨彲浠ユ寚鍚戜換鎰忕被鍨嬬殑鍐呭瓨鍧椼傚洜姝わ紝sizeof(str)鍊間負鏁扮粍鍗犳嵁鐨勫唴瀛樼┖闂村ぇ灝忓嵆10涓瓧鑺傦紝鑰宻izeof(pstr)鍊間負鎸囬拡鐨勫煎崰鎹殑鍐呭瓨絀洪棿澶у皬鍗?涓瓧鑺傘?/strong>

2.鏁扮粍鍚嶄笉鏄寚閽堬紝浣嗘槸鍦ㄤ竴瀹氱殑鎯呭喌涓嬭漿鎹負鎸囦唬鏁扮粍鐨勯鍦板潃鐨勬寚閽堬紝鑰岃繖涓暟緇勫悕杞負鐨勬寚閽堝彧鑳芥槸鎸囬拡甯擱噺銆?br>鍦ㄤ互涓嬩袱縐嶆儏鍐典笅鎵嶈兘榪涜榪欑杞崲錛?br>a.鍦ㄧ▼搴?絎簩琛屼唬鐮佷腑錛屽皢鏁扮粍鍚嶇洿鎺ヨ祴鍊肩粰鎸囬拡錛屾鏃舵暟緇勫悕杞崲涓烘寚鍚戞暟緇勭殑棣栧崟鍏冪殑甯擱噺鎸囬拡銆?br>b.鐩存帴灝嗘暟緇勫悕浣滀負鎸囬拡褰㈠弬鐨勬椂鍊欙紝鏁扮粍鍚嶅垯杞崲涓烘寚鍚戞暟緇勭殑棣栧崟鍏冪殑甯擱噺鎸囬拡榪涜浼犻掞紝濡備笅紼嬪簭2錛?br>
void fun(char str[])
{
cout<<
str++;
}
void main()
{

char str1[5];
fun(str1);

}

娉ㄦ剰錛氭暟緇勫悕浣滀負鍑芥暟褰㈠弬榪涜浼犻掓椂錛屽湪瀛愬嚱鏁頒綋鍐咃紝瀹冨凡緇忎笉鍐嶆槸涓涓寚閽堝父閲忥紝鑰屾槸鍙樻垚涓涓湡姝g殑鎸囬拡錛屽彲浠ヨ繘琛屽鍑忕瓑鎿嶄綔錛屽彲浠ヨ淇敼銆傛墍浠ョ▼搴?涓瓙紼嬪簭絎竴鏉¤鍙ヨ緭鍑虹殑sizeof(str)鐨勫間負4.

鏃㈢劧鏁扮粍鍚嶅彲浠ヨ鐪嬩綔鎸囬拡甯擱噺錛岃屽父閲忔槸涓嶈兘淇敼鐨勶紝閭d箞濡備笅浠g爜鏄笉鍏佽鐨勶細

char str[10];
str++;

浣嗗涓嬩唬鐮佸垯鍚堟硶鐨勶細

char str[10];
char *pstr=str;
pstr++;

3.浣跨敤鎸囬拡璁塊棶鏁扮粍鍜屼嬌鐢ㄦ暟緇勫悕璁塊棶鏁扮粍鏈川涓嶅悓銆?br>渚嬪錛?br>
char str[7]=”ksarea”;
char *pstr=str;
cout<<<


鍏朵腑str[3]鍜宲str[3]榪斿洖鐨勯兘鏄瓧絎?#8217;r'錛屼絾鏄紪璇戝櫒浜х敓鐨勬墽琛屼唬鐮佸嵈涓嶄竴鏍楓傚浜巗tr[3]錛屾墽琛屼唬鐮佹槸浠巗tr寮濮嬶紝鍚戝悗縐誨姩涓や釜瀛楄妭錛岀劧鍚庡彇鍑哄叾涓殑瀛楃錛涜屽浜巔str[3]錛屾墽琛屼唬鐮佹槸浠巔str涓彇鍑哄湴鍧錛岀劧鍚庡湪鍏朵笂鍔?錛岀劧鍚庡彇鍑哄搴斿唴瀛樹腑鐨勫瓧絎︺?/strong>褰撶劧錛屽鏋減str鏄寚鍚慽nt鍨嬬殑鎸囬拡錛岄偅涔坧str[3]鐨勫鐞嗚繃紼嬫槸浠巔str涓彇鍑哄湴鍧錛岀劧鍚庡湪鍏朵笂鍔犱笂3*sizeof(int)錛屾渶鍚庡彇鍑哄搴斿唴瀛樹腑鐨勫瓧絎︼紝鍏朵粬鐨勬暟鎹被鍨嬩竴嬈$被鎺ㄣ?

luis 2011-02-14 01:08 鍙戣〃璇勮
]]>
Java 鍛藉悕瑙勮寖zthttp://www.shnenglu.com/luyulaile/archive/2010/12/21/137128.htmlluisluisTue, 21 Dec 2010 08:44:00 GMThttp://www.shnenglu.com/luyulaile/archive/2010/12/21/137128.htmlhttp://www.shnenglu.com/luyulaile/comments/137128.htmlhttp://www.shnenglu.com/luyulaile/archive/2010/12/21/137128.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/137128.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/137128.html瀹屽叏鐗坖ava瑙勮寖錛?a >http://www.huihoo.org/code/java_code_conventions.html#71

 



luis 2010-12-21 16:44 鍙戣〃璇勮
]]>
switch琛ㄨ揪寮?/title><link>http://www.shnenglu.com/luyulaile/archive/2010/12/19/136959.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Sun, 19 Dec 2010 13:41:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2010/12/19/136959.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/136959.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2010/12/19/136959.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/136959.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/136959.html</trackback:ping><description><![CDATA[<span style="COLOR: red"><font size=2>switch(琛ㄨ揪寮?<br>{ <br>      case 甯擱噺琛ㄨ揪寮?:<br>         璇彞1;<br>      break;<br>      <br>      case 甯擱噺琛ㄨ揪寮?:<br>         璇彞2;<br>      break; </font> <p><font size=2></font></p> <p><font size=2>……<br>      case 甯擱噺琛ㄨ揪寮弉:<br>         璇彞n;<br>      break; </font></p> <p><font size=2>      default:<br>         璇彞n+1;<br>      break;<br>}</font></p> </span> <img src ="http://www.shnenglu.com/luyulaile/aggbug/136959.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2010-12-19 21:41 <a href="http://www.shnenglu.com/luyulaile/archive/2010/12/19/136959.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>argmaxhttp://www.shnenglu.com/luyulaile/archive/2010/12/19/136937.htmlluisluisSun, 19 Dec 2010 06:58:00 GMThttp://www.shnenglu.com/luyulaile/archive/2010/12/19/136937.htmlhttp://www.shnenglu.com/luyulaile/comments/136937.htmlhttp://www.shnenglu.com/luyulaile/archive/2010/12/19/136937.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/136937.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/136937.html 



luis 2010-12-19 14:58 鍙戣〃璇勮
]]>
JAVA鑾峰彇闅忔満鏁?/title><link>http://www.shnenglu.com/luyulaile/archive/2010/12/19/136893.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Sat, 18 Dec 2010 16:56:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2010/12/19/136893.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/136893.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2010/12/19/136893.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/136893.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/136893.html</trackback:ping><description><![CDATA[<p>鏈枃鏉ヨ嚜CSDN鍗氬<a >http://blog.csdn.net/pointbin/archive/2006/01/12/576957.aspx</a></p> <p> <br>鍦╦ava.lang.Math涓湁涓狹ath.random()鏂規硶錛屽畠鍙互浜х敓0-1涔嬮棿錛堝寘鎷?浣嗕笉鍖呮嫭1錛夌殑浠繪剰灝忔暟<br><br><br>鍦↗ava涓垜浠彲浠ヤ嬌鐢╦ava.util.Random綾繪潵浜х敓涓涓殢鏈烘暟鍙戠敓鍣ㄣ傚畠鏈変袱縐嶅艦寮忕殑鏋勯犲嚱鏁幫紝鍒嗗埆鏄疪andom()鍜孯andom(long seed)銆俁andom()浣跨敤褰撳墠鏃墮棿鍗砈ystem.currentTimeMillis()浣滀負鍙戠敓鍣ㄧ殑縐嶅瓙錛孯andom(long seed)浣跨敤鎸囧畾鐨剆eed浣滀負鍙戠敓鍣ㄧ殑縐嶅瓙銆?/p> <p>        闅忔満鏁板彂鐢熷櫒(Random)瀵硅薄浜х敓浠ュ悗錛岄氳繃璋冪敤涓嶅悓鐨刴ethod錛歯extInt()銆乶extLong()銆乶extFloat()銆乶extDouble()絳夎幏寰椾笉鍚岀被鍨嬮殢鏈烘暟銆?/p> <p>       1>鐢熸垚闅忔満鏁?br>           Random random = new Random();<br>           Random random = new Random(100);//鎸囧畾縐嶅瓙鏁?00<br>           random璋冪敤涓嶅悓鐨勬柟娉曪紝鑾峰緱闅忔満鏁般?br>           濡傛灉2涓猂andom瀵硅薄浣跨敤鐩稿悓鐨勭瀛愶紙姣斿閮芥槸100錛夛紝騫朵笖浠ョ浉鍚岀殑欏哄簭璋冪敤鐩稿悓鐨勫嚱鏁幫紝閭e畠浠繑鍥炲煎畬鍏ㄧ浉鍚屻傚涓嬮潰浠g爜涓袱涓猂andom瀵硅薄鐨勮緭鍑哄畬鍏ㄧ浉鍚?br>          import java.util.*;<br>          class TestRandom {<br>                public static void main(String[] args) {<br>                     Random random1 = new Random(100);<br>                     System.out.println(random1.nextInt());<br>                     System.out.println(random1.nextFloat());<br>                     System.out.println(random1.nextBoolean());<br>                     Random random2 = new Random(100);<br>                     System.out.println(random2.nextInt());<br>                     System.out.println(random2.nextFloat());<br>                     System.out.println(random2.nextBoolean());<br>                }<br>            }</p> <p>        2>鎸囧畾鑼冨洿鍐呯殑闅忔満鏁?br>             闅忔満鏁版帶鍒跺湪鏌愪釜鑼冨洿鍐?浣跨敤妯℃暟榪愮畻絎?<br>            import java.util.*;<br>                 class TestRandom {<br>                      public static void main(String[] args) {<br>                           Random random = new Random();<br>                           for(int i = 0; i < 10;i++) {<br>                               System.out.println(Math.abs(random.nextInt())%10);<br>                           }<br>                      }<br>                 }<br>             鑾峰緱鐨勯殢鏈烘暟鏈夋鏈夎礋鐨勶紝鐢∕ath.abs浣胯幏鍙栨暟鎹寖鍥翠負闈炶礋鏁?/p> <p>       3>鑾峰彇鎸囧畾鑼冨洿鍐呯殑涓嶉噸澶嶉殢鏈烘暟<br>            import java.util.*;<br>            class TestRandom {<br>                  public static void main(String[] args) {<br>                       int[] intRet = new int[6]; <br>                       int intRd = 0; //瀛樻斁闅忔満鏁?br>                       int count = 0; //璁板綍鐢熸垚鐨勯殢鏈烘暟涓暟<br>                       int flag = 0; //鏄惁宸茬粡鐢熸垚榪囨爣蹇?br>                       while(count<6){<br>                            Random rdm = new Random(System.currentTimeMillis());<br>                            intRd = Math.abs(rdm.nextInt())%32+1;<br>                            for(int i=0;i<count;i++){<br>                                if(intRet[i]==intRd){<br>                                    flag = 1;<br>                                    break;<br>                                }else{<br>                                    flag = 0;<br>                                }<br>                            }<br>                            if(flag==0){<br>                                intRet[count] = intRd;<br>                                count++;<br>                            }<br>                   }<br>                  for(int t=0;t<6;t++){<br>                      System.out.println(t+"->"+intRet[t]);<br>                  }<br>               }<br>            }</p> <p> </p> <img src ="http://www.shnenglu.com/luyulaile/aggbug/136893.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2010-12-19 00:56 <a href="http://www.shnenglu.com/luyulaile/archive/2010/12/19/136893.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>joj 1097 System overload 綰︾憻鑺棶棰?綆鍗曢http://www.shnenglu.com/luyulaile/archive/2009/07/23/90881.htmlluisluisWed, 22 Jul 2009 23:23:00 GMThttp://www.shnenglu.com/luyulaile/archive/2009/07/23/90881.htmlhttp://www.shnenglu.com/luyulaile/comments/90881.htmlhttp://www.shnenglu.com/luyulaile/archive/2009/07/23/90881.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/90881.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/90881.html棰樻剰濂界悊瑙o紝鏃墮棿涓婃彁楂樹笉浜嗭紝嫻嬭瘯鏁版嵁寰堝皯鍙互浜よ〃

鐐?灞曞紑


luis 2009-07-23 07:23 鍙戣〃璇勮
]]>
c/c++杈撳叆杈撳嚭鍏ㄥ綊綰?/title><link>http://www.shnenglu.com/luyulaile/archive/2009/07/21/90735.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Tue, 21 Jul 2009 07:18:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2009/07/21/90735.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/90735.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2009/07/21/90735.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/90735.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/90735.html</trackback:ping><description><![CDATA[<p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">浠婂ぉ鐪嬪畬涓綃囩墰浜哄崥鏂囷紝鍙楃泭鍖祬錛屽皬璁頒竴涓嬨傚師鏂囨洿璇︾粏<a >http://blog.csdn.net/lewsn2008/archive/2008/04/16/2295790.aspx</a><br>棣栧厛鎴戜滑鍛㈢湅涓涓嬭緭鍏ユ搷浣滅殑鍘熺悊錛?紼嬪簭鐨勮緭鍏ラ兘寤烘湁涓涓紦鍐插尯錛屽嵆杈撳叆緙撳啿鍖恒備竴嬈¤緭鍏ヨ繃紼嬫槸榪欐牱鐨勶紝褰撲竴嬈¢敭鐩樿緭鍏ョ粨鏉熸椂浼氬皢杈撳叆鐨勬暟鎹瓨鍏ヨ緭鍏ョ紦鍐插尯錛岃宑in絳夎緭鍏ヨ緭鍑哄嚱鏁扮洿鎺ヤ粠杈撳叆緙撳啿鍖轟腑鍙栨暟鎹傛鍥犱負cin絳夎緭鍏ヨ緭鍑哄嚱鏁版槸鐩存帴浠庣紦鍐插尯鍙栨暟鎹殑錛屾墍浠ユ湁鏃跺欏綋緙撳啿鍖轟腑鏈夋畫鐣欐暟鎹椂錛宑in鍑芥暟浼氱洿鎺ュ彇寰楄繖浜涙畫鐣欐暟鎹屼笉浼氳姹傞敭鐩樿緭鍏ャ?br>---------------</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">1錛岃娉ㄦ剰涓嶅悓鐨勫嚱鏁版槸鍚︽帴鍙楃┖鏍肩銆佹槸鍚﹁垗寮冩渶鍚庣殑鍥炶濺絎︾殑闂!</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">璇誨彇瀛楃鏃訛細</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">scanf()浠pace絀烘牸銆丒nter銆乀ab緇撴潫涓嬈¤緭鍏ワ紝涓嶄細鑸嶅純鏈鍚庣殑鍥炶濺絎︼紙鍗沖洖杞︾浼氭畫鐣欏湪緙撳啿鍖轟腑錛夛紝錛堝尯鍒瀛楃涓叉椂浼氭竻妤氾級//鎵浠ュ彲浠ョ敤getchar()娓呴櫎錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">getchar()浠nter緇撴潫杈撳叆錛屼篃涓嶄細鑸嶅純鏈鍚庣殑鍥炶濺絎︼紱</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">璇誨彇瀛楃涓叉椂錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">scanf()浠pace銆丒nter銆乀ab緇撴潫涓嬈¤緭鍏ワ紝浼氳垗寮冩渶鍚庣殑鍥炶濺絎︼紙鍖哄埆璇誨瓧絎︽椂錛夊拰鎵鏈夌殑絀烘牸絳夌瓑銆?o:p></o:p></p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">gets()浠nter緇撴潫杈撳叆錛堢┖鏍間笉緇撴潫錛夛紝鎺ュ彈絀烘牸錛屼細鑸嶅純鏈鍚庣殑鍥炶濺絎︼紒</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana"><o:p> </o:p></p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">絎簩錛氫負浜嗛伩鍏嶅嚭鐜頒笂榪伴棶棰橈紝蹇呴』瑕佹竻絀虹紦鍐插尯鐨勬畫鐣欐暟鎹紝鍙互鐢ㄤ互涓嬬殑鏂規硶瑙e喅錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">鏂規硶1錛欳璇█閲屾彁渚涗簡鍑芥暟娓呯┖緙撳啿鍖猴紝鍙鍦ㄨ鏁版嵁涔嬪墠鍏堟竻絀虹紦鍐插尯灝辨病闂浜嗭紒<o:p></o:p></p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">       榪欎釜鍑芥暟鏄痜flush(stdin)銆?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">鏂規硶2錛氳嚜宸卞彇鍑虹紦鍐插尯閲岀殑孌嬬暀鏁版嵁銆?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">       scanf("%[^\n]",string);</p> -------------------------<br>cin鐨勫闂?br> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">涓. cin<<</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">璇ユ搷浣滅鏄牴鎹悗闈㈠彉閲忕殑綾誨瀷璇誨彇鏁版嵁銆?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">杈撳叆緇撴潫鏉′歡   錛氶亣鍒癊nter銆丼pace銆乀ab閿?榪欎釜寰堥噸瑕侊紒)</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">瀵圭粨鏉熺鐨勫鐞?錛氭竻妤氱紦鍐插尯涓嬌寰楄緭鍏ョ粨鏉熺殑緇撴潫絎?Enter銆丼pace銆乀ab)</p> (榪欓噷鏈変竴鐐歸棶棰橈紝<br>int i;<br>char c[100];<br>cin>>i;<br>cin.getline(str,100);<br>cout<<str;<br>濡傛灉杈撳叆鏄細12     adjf鍥炶濺<br>杈撳嚭灝嗗厛鏄┖鏍肩劧鍚巃djf錛?br>濡傛灉杈撳叆鏄細12鍥炶濺adjf鍥炶濺<br>杈撳嚭灝嗘槸adjf.<br>鐪嬫潵cin>>瑕佸湪榪炵敤鏃訛紝姣斿cin>>a>>b;鎴栬卌in>>a;cin>>b娑堥櫎絀烘牸鑳藉姏鎵嶄綋鐜般?br>)<br> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">浜岋紟cin.get()</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">璇ュ嚱鏁版湁涓夌鏍煎紡錛氭棤鍙傦紝涓鍙傛暟錛屼簩鍙傛暟</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">鍗砪in.get(),  cin.get(char ch),  cin.get(array_name, Arsize)</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana"> </p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">        錛坕錛夎鍙栧瓧絎︾殑鎯呭喌錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">杈撳叆緇撴潫鏉′歡錛欵nter閿紙閬囩┖鏍間笉緇撴潫錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">瀵圭粨鏉熺澶勭悊錛氫笉涓㈠純緙撳啿鍖轟腑鐨凟nter</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">cin.get() 涓?cin.get(char ch)鐢ㄤ簬璇誨彇瀛楃錛屼粬浠殑浣跨敤鏄浉浼肩殑錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">鍗籌細ch=cin.get() 涓?cin.get(ch)鏄瓑浠風殑銆?br></p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">嫻嬭瘯紼嬪簭錛?br>#include <iostream></p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">using namespace std;</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">int main()</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">{</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">       char c1, c2;</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">       cin.get(c1);</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">       cin.get(c2);</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">       cout<<c1<<" "<<c2<<endl;   // 鎵撳嵃涓や釜瀛楃</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">       cout<<(int)c1<<" "<<(int)c2<<endl; // 鎵撳嵃榪欎袱涓瓧絎︾殑ASCII鍊?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">       return 0; </p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">}</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">嫻嬭瘯涓杈撳叆錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">a[Enter]</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">杈撳嚭:</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">a</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana"> </p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">97 10</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">銆愬垎鏋愩戜細鍙戠幇鍙墽琛屼簡涓嬈′粠閿洏杈撳叆錛屾樉鐒剁涓涓瓧絎﹀彉閲忓彇鐨?a', 絎簩涓彉閲忓彇鐨勬槸Enter(ASCII鍊間負10)錛岃繖鏄洜涓鴻鍑芥暟涓嶄涪寮冧笂嬈¤緭鍏ョ粨鏉熸椂鐨凟nter瀛楃錛屾墍浠ョ涓嬈¤緭鍏ョ粨鏉熸椂緙撳啿鍖轟腑孌嬬暀鐨勬槸涓婃杈撳叆緇撴潫鏃剁殑Enter瀛楃錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana"> </p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">嫻嬭瘯浜岃緭鍏ワ細</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">a b[Enter]</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">杈撳嚭錛?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">a </p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">97 32</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">銆愬垎鏋愩戞樉鐒剁涓涓瓧絎﹀彉閲忓彇鐨?a', 絎簩涓彉閲忓彇鐨勬槸Space(ASCII鍊間負32)銆傚師鍥犲悓涓婏紝娌℃湁涓㈠純Space瀛楃銆?/p> <p style="FONT-SIZE: 18pt; FONT-FAMILY: Verdana">            錛坕i錛夎鍙栧瓧絎︿覆鐨勬儏鍐碉細</p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">cin.get(array_name, Arsize)鏄敤鏉ヨ鍙栧瓧絎︿覆鐨勶紝鍙互鎺ュ彈絀烘牸瀛楃錛岄亣鍒癊nter緇撴潫杈撳叆錛屾寜鐓ч暱搴?Arsize)璇誨彇瀛楃, 浼氫涪寮冩渶鍚庣殑Enter瀛楃銆?/p> <span style="FONT-SIZE: 14pt">                      <span style="FONT-SIZE: 18pt">錛坕 i i錛塩in.getline()</span></span> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">cin.getline() 涓?cin.get(array_name, Arsize)鐨勮鍙栨柟寮忓樊涓嶅錛屼互Enter緇撴潫錛屽彲浠ユ帴鍙楃┖鏍煎瓧絎︺傛寜鐓ч暱搴?Arsize)璇誨彇瀛楃, 浼氫涪寮冩渶鍚庣殑Enter瀛楃銆?/p> <p style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">浣嗘槸榪欎袱涓嚱鏁版槸鏈夊尯鍒殑錛?/p> cin.get(array_name, Arsize)<br><span style="COLOR: #ff0000">褰撹緭鍏ョ殑瀛楃涓茶秴闀挎椂錛屼笉浼氬紩璧穋in鍑芥暟鐨勯敊璇紝鍚庨潰鐨刢in鎿嶄綔浼氱戶緇墽琛岋紝鍙槸鐩存帴浠庣紦鍐插尯涓彇鏁版嵁銆備絾鏄痗in.getline()<br><br>褰撹緭鍏ヨ秴闀挎椂錛屼細寮曡搗cin鍑芥暟鐨勯敊璇紝鍚庨潰鐨刢in鎿嶄綔灝嗕笉鍐嶆墽琛屻傦紙鍏蜂綋鍘熷洜灝嗗湪涓嬩竴閮ㄥ垎"cin鐨勯敊璇鐞?涓緇嗕粙緇嶏級<br></span><br>------------<br>cin鐨勯敊璇鐞?br><br> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">紼嬪簭鎵ц鏃舵湁涓涓爣蹇楀彉閲忔潵鏍囧織杈撳叆鐨勫紓甯哥姸鎬侊紝鍏朵腑鏈変笁浣嶆爣蹇椾綅鍒嗗埆鐢ㄦ潵鏍囧織涓夌寮傚父淇℃伅錛屼粬浠垎鍒槸錛?/span><span lang=EN-US>failbit</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛?/span><span lang=EN-US>eofbit</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛?/span><span lang=EN-US>badbit</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆傝繖涓変釜鏍囧織浣嶅湪鏍囧織鍙橀噺涓槸榪欐牱鍒嗛厤鐨勶細</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>____________________________________</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>|<span style="mso-spacerun: yes">     </span>2<span style="mso-spacerun: yes">     </span>|<span style="mso-spacerun: yes">     </span>1<span style="mso-spacerun: yes">    </span>|<span style="mso-spacerun: yes">     </span>0<span style="mso-spacerun: yes">     </span>|</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>|<span style="mso-spacerun: yes">  </span>failbit<span style="mso-spacerun: yes">  </span>|<span style="mso-spacerun: yes">  </span>eofbit<span style="mso-spacerun: yes">  </span>|<span style="mso-spacerun: yes">   </span>badbit<span style="mso-spacerun: yes">  </span>|</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>|___________|__________|___________|</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐪嬩竴涓嬭繖鍑犱釜鏍囧織浣嶇殑浣滅敤</span><span lang=EN-US>(</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寮曠敤</span><span lang=EN-US>msdn)</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>badbit, to record a loss of integrity of the stream buffer.</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>eofbit, to record end-of-file while extracting from a stream.</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>failbit, to record a failure to extract a valid field from a stream.</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>In addition, a useful value is goodbit, where no bits are set.</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鎺ヤ笅鏉ユ垜涔堢湅鍑犱釜</span><span lang=EN-US>ios</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">綾葷殑鏁版嵁瀹氫箟</span><span lang=EN-US>(</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寮曠敤</span><span lang=EN-US>msdn)</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>typedef T2 iostate; </span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>static const iostate badbit, eofbit, failbit, goodbit;</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪欓噷</span><span lang=EN-US>ios</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">綾誨畾涔変簡榪欏洓涓父閲?/span><span lang=EN-US>badbit, eofbit, failbit, goodbit</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛屽叾瀹炶繖鍥涗釜鏍囧織甯擱噺灝辨槸鍙栧搴旀爣蹇椾綅鐨勬帺鐮侊紝涔熷嵆杈撳叆鐨勫洓縐嶅紓甯告儏鍐碉紒</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">浠ヤ笂鍥涗釜甯擱噺瀵瑰簲鐨勫彇鍊間負錛?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>ios::badbit<span style="mso-spacerun: yes">    </span>001<span style="mso-spacerun: yes">   </span></span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">杈撳叆錛堣緭鍑猴級嫻佸嚭鐜拌嚧鍛介敊璇紝涓嶅彲鎸藉洖</span><span lang=EN-US><span style="mso-spacerun: yes">  </span></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>ios::eofbit<span style="mso-spacerun: yes">    </span>010<span style="mso-spacerun: yes">   </span></span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">宸茬粡鍒拌揪鏂囦歡灝?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>ios::failbit<span style="mso-spacerun: yes">   </span>100<span style="mso-spacerun: yes">   </span></span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">杈撳叆錛堣緭鍑猴級嫻佸嚭鐜伴潪鑷村懡閿欒錛屽彲鎸藉洖</span><span lang=EN-US> </span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>ios::goodbit<span style="mso-spacerun: yes">   </span>000<span style="mso-spacerun: yes">   </span></span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">嫻佺姸鎬佸畬鍏ㄦ甯?/span><span lang=EN-US>, </span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍚勫紓甯告爣蹇椾綅閮戒負</span><span lang=EN-US>0</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt">濡傛灉鍑虹幇杈撳叆閿欒錛屽垯cin涓嶅啀宸ヤ綔錛屾垜浠彲浠ョ敤cin.clear()閲嶇疆鏍囪浣嶃?span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><br>嫻嬭瘯紼嬪簭</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>#include <iostream></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>using namespace std;</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>int main ()</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>{</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>char ch, str[20];</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>cin.getline(str, 5);</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>cout<<"flag1:"<<cin.good()<<endl;<span style="mso-spacerun: yes">    </span>// </span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏌ョ湅</span><span lang=EN-US>goodbit</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐘舵侊紝鍗蟲槸鍚︽湁寮傚父</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>cin.clear();<span style="mso-spacerun: yes">                         </span>// </span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">娓呴櫎閿欒鏍囧織</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>cout<<"flag1:"<<cin.good()<<endl;<span style="mso-spacerun: yes">    </span>// </span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">娓呴櫎鏍囧織鍚庡啀鏌ョ湅寮傚父鐘舵?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>cin>>ch; </span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>cout<<"str:"<<str<<endl;</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>cout<<"ch :"<<ch<<endl;</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-spacerun: yes"> </span>return 0;</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>}</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">嫻嬭瘯杈撳叆錛?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>12345[Enter]</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">杈撳嚭錛?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>flag1:0<span style="mso-spacerun: yes">  </span>// good()</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪斿洖</span><span lang=EN-US>false</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">璇存槑鏈夊紓甯?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>flag2:1<span style="mso-spacerun: yes">  </span>// good()</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪斿洖</span><span lang=EN-US>true</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">璇存槑錛?/span><span lang=EN-US>clear()</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">宸茬粡娓呴櫎浜嗛敊璇爣蹇?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>str:1234</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>ch :5</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><br>浣嗘槸褰撳墠涓嬈¤鍙栨暟鎹嚭閿欏悗錛屽鏋滅紦鍐插尯娌℃湁娓呯┖鐨勮瘽錛岄噸緗敊璇爣蹇楄繕涓嶅錛佽鏄兘灝嗙紦鍐插尯鐨勬畫鐣欐暟鎹竻絀轟簡灝卞ソ浜嗗摝錛佷笅闈㈡垜浠啀鏉ョ湅涓涓緢閲嶈鐨勫嚱鏁幫紒cin.ignore()<br></span></p> <span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">榪欎釜鍑芥暟鐢ㄦ潵涓㈠純杈撳叆緙撳啿鍖轟腑鐨勫瓧絎︼紝絎竴鍙傛暟瀹氫箟涓涓暟錛岀浜屼釜鍙傛暟瀹氫箟涓涓瓧絎﹀彉閲忋?/span><br>渚嬶細</span><span lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 瀹嬩綋">cin.ignore(5, 'a'); </span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">鍑芥暟灝嗕笉鏂粠緙撳啿鍖轟腑鍙栦竴涓瓧絎︿涪寮冿紝鐩村埌涓㈠純鐨勫瓧絎︽暟杈懼埌</span><span lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 瀹嬩綋">5</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">鎴栬呰鍙栫殑瀛楃涓?/span><span lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 瀹嬩綋">'a'</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">銆?/span><br> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍏跺疄璇ュ嚱鏁版渶甯哥敤鐨勬柟寮忔槸榪欐牱鐨勶紝灝嗙涓涓弬鏁拌鐨勯潪甯稿ぇ錛屽皢絎簩涓弬鏁拌涓?/span><span lang=EN-US>'\n'</span><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛岃繖鏍峰氨鍙互緙撳啿鍖轟腑鍥炶濺絎︿腑鐨勬墍鏈夋畫鐣欐暟鎹紝鍥犱負涓鑸儏鍐典笅鍓嶉潰杈撳叆孌嬬暀鐨勬暟鎹槸娌℃湁鐢ㄧ殑錛屾墍浠ュ湪榪涜鏂頒竴嬈¤緭鍏ユ搷浣滃墠灝嗙紦鍐插尯涓墍鏈夋暟鎹竻絀烘槸姣旇緝鍚堢悊銆?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">濡傦細</span><span lang=EN-US>cin.ignore(1024, '\n'); </span></p> <br>------ <img src ="http://www.shnenglu.com/luyulaile/aggbug/90735.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2009-07-21 15:18 <a href="http://www.shnenglu.com/luyulaile/archive/2009/07/21/90735.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>joj 1946 compound wordshttp://www.shnenglu.com/luyulaile/archive/2009/07/19/90489.htmlluisluisSun, 19 Jul 2009 02:09:00 GMThttp://www.shnenglu.com/luyulaile/archive/2009/07/19/90489.htmlhttp://www.shnenglu.com/luyulaile/comments/90489.htmlhttp://www.shnenglu.com/luyulaile/archive/2009/07/19/90489.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/90489.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/90489.htmlSample Input
a
alien
born
less
lien
never
nevertheless
new
newborn
the
zebra

Sample Output

alien
newborn
杈撳叆鏄瓧鍏稿簭鐨勶紝棰樻剰灝辨槸璁蹭竴涓崟璇嶅垎鎴愪袱鍗婏紝涓斾袱鍗婇兘鍑虹幇鍦ㄨ緭鍏ヤ腑錛屽垯灝嗘鍗曡瘝杈撳嚭銆備笅闈㈢殑浠g爜鏄姣忎竴涓崟璇嶅皾璇曟墍鏈夌殑鍒嗘媶鏂規硶錛屼竴涓釜鍘誨鎵炬槸鍚︽媶鎴愮殑涓?/pre>
涓槸鍚﹂兘瀛樺湪錛屽鏋滀袱涓瓧涓查兘瀛樺湪錛屽垯杈撳嚭錛屽悓鏃惰煩鍑哄驚鐜紙鍚﹀垯鍙兘閲嶅杈撳嚭錛夈?/pre>
鍏跺疄鏈夋洿楂樻晥鐨勬柟娉曪紝灝辨槸鍒版瘡涓崟璇嶅墠闈㈠鎵炬槸鍚︽湁浠栫殑瀛椾覆錛堟瘮濡俷ewborn 鍓嶉潰鏈塶ew,neverthelsess 鍓嶉潰鏈塶ever錛夛紝鏈夌殑璇濓紝鍐嶆壘鍚庡崐閮ㄥ垎鏄惁鍦ㄨ緭鍏ヤ腑銆?/pre>
----
鑾峰彇瀛愪覆鐨勬柟娉曘?string   B   =   A.substr(start,length);   
  start涓哄瓙涓插湪A涓殑寮濮嬩綅緗?  
  length涓哄瓙涓茬殑闀垮害
渚嬪瓙   
  void   main()  
  {  
          string   st="ifn",b;  
  b=st.substr(0,2);  
  cout<<b;  
  }  
  緇撴灉   if
----
鐐規浠g爜


luis 2009-07-19 10:09 鍙戣〃璇勮
]]>鑾峰彇琛岃緭鍏ワ紝涓琛屼竴涓瓧絎︿覆http://www.shnenglu.com/luyulaile/archive/2009/07/18/90435.htmlluisluisSat, 18 Jul 2009 08:11:00 GMThttp://www.shnenglu.com/luyulaile/archive/2009/07/18/90435.htmlhttp://www.shnenglu.com/luyulaile/comments/90435.htmlhttp://www.shnenglu.com/luyulaile/archive/2009/07/18/90435.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/90435.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/90435.html2152: A Special Sorting
Status In/Out TIME Limit MEMORY Limit Submit Times Solved Users JUDGE TYPE
stdin/stdout 3s 8192K 356 152 Standard

Give you a sequence of words, can you sort them in dictionary order?

eg.

yes
accidental
baby
accept
accident
In dictionary order, those words should be printed as the following
accept
accident
accidental
baby
yes
But we will make an interesting rule this time. See your keyboard or the picture below:

there are ONLY 26 letters in lower-case we will use, and we assume that the letter above is bigger than the letter below, and the left is bigger than the right. For example, 'q' is bigger than 'a', 'c' is bigger than 'v'. So the example at the beginning whill be...

Input and Output

the input will only contain a sequence of words which is less than 1500. the output should print the sorted words each in a single line.

Sample Input

yes
accidental
baby
accept
accident

Sample Output

baby
accident
accidental
accept
yes

姘撮鍟婏紒
#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
int Map[27];
struct M{
 char s[30];
}S[1500];
char table[26]={'q','w','e','r','t','y','u','i','o','p','a','s','d',
'f','g','h','j','k','l','z','x','c','v','b','n','m'};
bool operator<(M a,M b)
{
 int i=strlen(a.s);
 int j=strlen(b.s);
 if(i<j)
 j=i;
 for(int k=0;k<j;k++)
 {
  if(Map[(a.s[k])-'a']<Map[(b.s)[k]-'a'])
  return false;
  if(Map[(a.s[k])-'a']>Map[(b.s)[k]-'a'])
  return true;
 }
 return i==j;//Èç¹ûabcd,abc,abcd<abc
}
void search(char key)
{
 int i;
for(i=0;i<26;i++)
{
 if(key==table[i])
 {
  Map[key-'a']=i;
  break;
 }
}
}
  int main()
  {
  freopen("s.txt","r",stdin);  
  freopen("key.txt","w",stdout);
  int i;
  string t;
  memset(S,0,sizeof(S));
  for(i=0;i<26;i++)
  {
  search('a'+i);
  }
  i=0;
  while(!cin.eof())
   { 
 cin.getline(S[i++].s,30);//涓嶈兘鐢╟in>>s;鍚﹀垯runtime  error
   }
 sort(S,S+i-1);
 for(int j=0;j<i-1;j++)//蹇呴』鐢╥-1,鏈鍚庤繕鏈変釜絀鴻銆?br> cout<<S[j].s<<endl;
  //system("PAUSE");
  return   0;
  }
濂囨殑鏄湪vc涓婅兘鐢?br>string s ;
while(cin>>s)
{};
鍦╠ev c++ 涓婁笉琛屻?
鍚庢潵鎵嶅彂鐜板彲浠?br>string s ;
while(cin>>s)
{};
浣嗘槸涓嶈兘鍔?memset(S,0,sizeof(S));


luis 2009-07-18 16:11 鍙戣〃璇勮
]]>
joj 1253 Magic Numbers 涓嶉毦錛屼絾鏄彲浠ュ仛鍋?/title><link>http://www.shnenglu.com/luyulaile/archive/2009/07/17/90393.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Fri, 17 Jul 2009 15:21:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2009/07/17/90393.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/90393.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2009/07/17/90393.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/90393.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/90393.html</trackback:ping><description><![CDATA[<p>鍙互鐢╨ong long錛屽彲浠ヤ笉鐢ㄩ珮綺懼害綆楁硶錛堝ぇ鏁存暟涔樻硶錛夈?br>浠?寮濮嬮亶鍘嗗埌9999999999/n;鍥犱負鏈澶氬彧鏈?0浣嶃傜浉涔樹箣縐篃搴斿綋灝忎簬9999999999.</p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000">  n</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">9999999999.0</span><span style="COLOR: #000000">;<br>  </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000">  m,temp;<br>  </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">m)<br> {<br>    <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">m;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>         {<br>          </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍒ゆ柇</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">         }<br>}</span></div> <img src ="http://www.shnenglu.com/luyulaile/aggbug/90393.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2009-07-17 23:21 <a href="http://www.shnenglu.com/luyulaile/archive/2009/07/17/90393.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>joj 1199 姹俷!鏈鍙寵竟涓浣嶉潪闆舵暟http://www.shnenglu.com/luyulaile/archive/2009/07/08/89533.htmlluisluisWed, 08 Jul 2009 02:45:00 GMThttp://www.shnenglu.com/luyulaile/archive/2009/07/08/89533.htmlhttp://www.shnenglu.com/luyulaile/comments/89533.htmlhttp://www.shnenglu.com/luyulaile/archive/2009/07/08/89533.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/89533.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/89533.html姹傛ā鐨勬濇兂
#include<iostream>
#include<cstdlib>
#include<iomanip>
using namespace std;

  int main()
  {
  //freopen("s.txt","r",stdin);
  //freopen("key.txt","w",stdout);
  int n;
  int temp;
  while(cin>>n)
  {
  cout<<setw(5)<<n<<" -> " ;
  temp=1;
  for(int j=1;j<=n;j++)
  {
   int i=j;
   while(i%10==0)
   {
    i/=10;
   }
   while(i%5==0)
   {
    i/=5;
    temp/=2;
   }
   
   temp*=i;
   
  //¼ÆËãĩλ
   temp%=100000;
  }
  while(temp%10==0)
  temp/=10;
  temp%=10;
  cout<<temp<<endl;
  }

  //system("PAUSE");
  return   0;
  }
涓縐嶆槸鍒嗙被鐨勬濇兂

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
 long a[10001]={0,1,2,6,4,2},b[5]={0,2,4,8,6},i,m,n;
 for(i=6;i<=10000;i++)
 {
  m=i%5;
  n=i/5;
  if(m!=0)
   a[i]=a[i-1]*i%10;
  else
   a[i]=b[(n-1)%4+1]*a[n]%10;
 }
 while(cin>>n)
  cout<<setw(5)<<n<<" -> "<<a[n]<<endl;
 return 0;
}



luis 2009-07-08 10:45 鍙戣〃璇勮
]]>
joj 1125 spell checker瀛楃涓插鐞?maphttp://www.shnenglu.com/luyulaile/archive/2009/07/06/89395.htmlluisluisMon, 06 Jul 2009 12:13:00 GMThttp://www.shnenglu.com/luyulaile/archive/2009/07/06/89395.htmlhttp://www.shnenglu.com/luyulaile/comments/89395.htmlhttp://www.shnenglu.com/luyulaile/archive/2009/07/06/89395.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/89395.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/89395.html
Status In/Out TIME Limit MEMORY Limit Submit Times Solved Users JUDGE TYPE
stdin/stdout 3s 8192K 135 46 Standard

You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms.

If the word is absent in the dictionary then it can be replaced by correct words (from the dictionary) that can be obtained by one of the following operations:

  • deleting of one letter from the word;
  • replacing of one letter in the word with an arbitrary letter;
  • inserting of one arbitrary letter into the word.

Your task is to write the program that will find all possible replacements from the dictionary for every given word.

Input

This problem consists of several test cases, each of which is described below:

The first part of each test case contains all words from the dictionary. Each word occupies its own line. This part is finished by the single character '#' on a separate line. All words are different. There will be at most 10000 words in the dictionary.

The next part of the test case contains all words that are to be checked. Each word occupies its own line. This part is also finished by the single character '#' on a separate line. There will be at most 50 words that are to be checked.

All words in the input (words from the dictionary and words to be checked) consist only of small alphabetic characters and each one contains 15 characters at most.

The first line of the input contains an integer N, which is the number of test cases in the input, followed by N test cases described above.

Output

For each test case, first write to the output 'Scenario #k:', where k is the number of test case of input. Then on the next line write to the output exactly one line for every checked word in the order of their appearance in the second part of the test case. If the word is correct (i.e. it exists in the dictionary) write the message: "<checked word> is correct". If the word is not correct then write this word first, then write the character ':' (colon), and after a single space write all its possible replacements, separated by spaces. The replacements should be written in the order of their appearance in the dictionary (in the first part of the input file). If there are no replacements for this word then the line feed should immediately follow the colon.

Print a blank line after each test case.

Sample Input

1
i
is
has
have
be
my
more
contest
me
too
if
award
#
me
aware
m
contest
hav
oo
or
i
fi
mre
#

Sample Output

Scenario #1:
me is correct
aware: award
m: i my me
contest is correct
hav: has have
oo: too
or:
i is correct
fi: i
mre: more me

鍚彂錛歮ap鐢ㄤ簬鏌ユ壘瀛楃涓茶繕鏄緢鐖界殑銆?br>
#include<iostream>
#include
<cstdlib>
#include
<map>
#include
<math.h>
#include
<string>
using namespace std;
map 
<string,int> ans;
bool solve(char *s,char *key)
{
    
int i=strlen(s);
    
int j=strlen(key);
    
int num=0;
    
if(abs(i-j)>1)
    
return false;
    
else
    {
        
if(i-j==1)//姣斿瓧鍏鎬腑澶氫竴涓?nbsp;
        {
            
for(int k=0;k<j&&num<=2;k++)
            {
                
if(s[k+num]!=key[k])
                {
                    num
++;
                    k
--;
                }
            }
            
if(num<=1)
            
return true;
            
else
            
return false;
        }
        
if(j-i==1)//姣斿瓧鍏鎬腑灝戜竴涓?nbsp;
        {
            
for(int k=0;k<i&&num<=2;k++)
            {
                
if(s[k]!=key[k+num])
                {
                    num
++;
                  k
--;
                } 
            }
            
if(num<=1)
            
return true;
            
else
            
return false;
        }
        
if(i==j)
        {
            
for(int k=0;k<i&&num<=2;k++)
            {
                
if(s[k]!=key[k])
                num
++;
            }
            
if(num==1)
            
return true;
            
else
            
return false;
        }
    }
}
  
int main()
  {
  freopen(
"s.txt","r",stdin);
  freopen(
"key.txt","w",stdout);
  
int num,casetime=0;
  
int i,j,k;
  cin
>>num;
  
char s[16];
  
char str[10000][16];
  
while(num--)
  {
        casetime
++;
        cout
<<"Scenario #"<<casetime<<":"<<endl;
        ans.clear();
        i
=0;
        
while(1)
        {
            scanf(
"%s",&str[i]);
            
if(str[i][0]=='#')
              
break;
            ans[str[i]]
=1;
            i
++;
        }
        
while(1)
        {
            scanf(
"%s",&s);
            
if(s[0]=='#')
              
break;
            
if(ans[s]==1
            {
                cout
<<s<<" is correct"<<endl;

            } 
            
else
            {
                cout
<<s<<":";
               
for(int j=0;j<i;j++)
              {
                
if(solve(s,str[j]))
                  cout
<<" "<<str[j];
              }
              cout
<<endl;
            } 
        }
        cout
<<endl;
        
  }

  
//system("PAUSE");
  return   0;
  }


luis 2009-07-06 20:13 鍙戣〃璇勮
]]>
joj 1274 Pig Latin 瀛楃涓插鐞?/title><link>http://www.shnenglu.com/luyulaile/archive/2009/07/03/89183.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Fri, 03 Jul 2009 10:04:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2009/07/03/89183.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/89183.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2009/07/03/89183.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/89183.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/89183.html</trackback:ping><description><![CDATA[<div id="tzlztjh" class=prob_text> <p>You have decided that PGP encryptation is not strong enough for your email. You have decided to supplement it by first converting your clear text letter into Pig Latin before encrypting it with PGP. <h3>Input and Output</h3> <p>You are to write a program that will take in an arbitrary number of lines of text and output it in Pig Latin. Each line of text will contain one or more words. A ``word'' is defined as a consecutive sequence of letters (upper and/or lower case). Words should be converted to Pig Latin according to the following rules (non-words should be output exactly as they appear in the input): <ol> <li>Words that begin with a vowel (<tt>a</tt>, <tt>e</tt>, <tt>i</tt>, <tt>o</tt>, or <tt>u</tt>, and the capital versions of these) should just have the string ``<tt>ay</tt>'' (not including the quotes) appended to it. For example, ``<tt>apple</tt>'' becomes ``<tt>appleay</tt>''. <li>Words that begin with a consonant (any letter than is not <tt>A</tt>, <tt>a</tt>, <tt>E</tt>, <tt>e</tt>, <tt>I</tt>, <tt>i</tt>, <tt>O</tt>, <tt>o</tt>, <tt>U</tt> or <tt>u</tt>) should have the first consonant removed and appended to the end of the word, and then appending ``<tt>ay</tt>'' as well. For example, ``<tt>hello</tt>'' becomes ``<tt>ellohay</tt>''. <li>Do not change the case of any letter. </li> </ol> <h3>Sample Input</h3> <p> <pre>This is the input.</pre> <h3>Sample Output</h3> <p> <pre>hisTay isay hetay inputay.</pre> <p> </p> </div> <br>铏界劧棰樼洰闅懼害涓嶆槸寰堝ぇ錛屼絾鏄鎴戝惎鍙戞尯澶э紝紕板埌榪欑瀛楃涓插鐞嗙殑棰橈紝鏈濂藉氨鏄粺涓妯″紡錛?br>                  a=getchar():<br>                   while(flag)<br>           {      while()//鍒ゆ柇鏄惁絎﹀悎鏉′歡<br>                 { ----   ,<br>                        if((a=getchar())==EOF)//鑾峰彇a=getchar()<br>                                  flag=0;//鍒ゆ柇鏂囦歡鏄惁緇撴潫<br>                  }<br>                   while()//鍒ゆ柇鏄惁絎﹀悎鏉′歡<br>                 { ----   ,<br>                        if((a=getchar())==EOF)//鑾峰彇a=getchar()<br>                                  flag=0;//鍒ゆ柇鏂囦歡鏄惁緇撴潫<br>                  }<br>              }<br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cstdlib</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br><br>  </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br>  {<br> </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> freopen("s.txt","r",stdin);<br> </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> freopen("key.txt","w",stdout);</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">  </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> a;<br>  </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> flag</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,e</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,mark;<br>  </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> temp;<br>  </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> mar;<br>  a</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">getchar();<br>  </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (e)<br>  {<br>           mark</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>            </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">((a</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">z</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">(a</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">Z</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">))<br>          {<br>            temp</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ay</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>             </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(flag</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">)<br>            {<br>                 flag</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>                 </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">E</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">e</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">I</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">i</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">O</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">o</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">U</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">u</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br>                 cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">a;<br>                 </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> <br>                {<br>                    mark</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br>                    mar</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">a;<br>                }<br>           }<br>            </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br>          cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">a;<br>          </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">((a</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">getchar())</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">EOF)<br>                {<br>                    e</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>                    </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br>                 }    <br>         }<br>          </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(mark</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br>           {<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">mar;<br>           }    <br>          cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">temp;<br>           </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(a</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">z</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">(a</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">Z</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">a</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">))<br>           {<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">a;<br>                </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">((a</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">getchar())</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">EOF)<br>                {<br>                    e</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>                    </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br>                 }    <br>           } <br>           flag</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;   <br>  }<br>  </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">system("PAUSE");</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">  </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">   </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>  }<br></span></div> <img src ="http://www.shnenglu.com/luyulaile/aggbug/89183.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2009-07-03 18:04 <a href="http://www.shnenglu.com/luyulaile/archive/2009/07/03/89183.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>joj 2197 perfect set 搴忓伓瀵圭Оhttp://www.shnenglu.com/luyulaile/archive/2009/07/03/89171.htmlluisluisFri, 03 Jul 2009 08:43:00 GMThttp://www.shnenglu.com/luyulaile/archive/2009/07/03/89171.htmlhttp://www.shnenglu.com/luyulaile/comments/89171.htmlhttp://www.shnenglu.com/luyulaile/archive/2009/07/03/89171.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/89171.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/89171.htmlA perfect point set is a set of points, for every point (x,y) in this set, point (y,x) is also in this set.

Input

There are mutical cases for this problem. For every input case, there is a set. we give you the number of points in this set in the first line, followed by n lines,each give two integers x y.

Output

If this set is a perfect set, you should print "Yes", else you print "No".

Sample Input

4
1 4
4 1
2 5
5 2

Sample Output

Yes
1錛岃繖縐嶇被浼肩█鐤忕煩闃電殑鏁扮粍瀵逛竴鑸笉鐢ㄦ暟緇勫瓨鍌紝鐢ㄧ粨鏋勪綋姣旇緝濂?/pre>
2錛屾帓搴忓悗姣旇緝闈炲父鐨勫閥濡欍?/pre>
#include<iostream>
#include<cstdlib>
using namespace std;
struct mm{
double a;
double b;}M[100000];
bool  operator<(mm m1,mm m2)
{
if(m1.a<m2.a)
return true;
else
{
if(m1.a==m2.a&&m1.b<m2.b)
return true;
}
return false;
}
int main()
{
// freopen("s.txt","r",stdin);
// freopen("key.txt","w",stdout);
int num;
double a,b;
int temp=0;
while(cin>>num)
{
memset(M,0,sizeof(M));
temp=0;
for(int k=0;k<num;k++)
{
cin>>a>>b;
if(a<b)
{
M[temp].a=a;
M[temp].b=b;
temp++;
}
else if(a>b)//鎶奱鍜宐鐩哥瓑鐨勯兘鍘繪帀浜?
{
M[temp].a=b;
M[temp].b=a;
temp++;
}
}
if(temp%2!=0)cout<<"No"<<endl;
else
{
sort(M,M+temp);
int flag=0;
for(int p=0;p<temp;p+=2)
{
if(M[p].b!=M[p+1].b||M[p].a!=M[p+1].a)
{
flag=1;break;
}
}
if(flag==0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}
//system("PAUSE");
return   0;
}


luis 2009-07-03 16:43 鍙戣〃璇勮
]]>joj 1157 Station Balance 姘?/title><link>http://www.shnenglu.com/luyulaile/archive/2009/07/01/88970.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Wed, 01 Jul 2009 02:54:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2009/07/01/88970.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/88970.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2009/07/01/88970.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/88970.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/88970.html</trackback:ping><description><![CDATA[#include<iostream><br>#include<cstdlib><br>#include<iomanip><br>#include<algorithm> <br>#include<math.h><br>using namespace std;<br><br>  int main()<br>  {<br>//freopen("s.txt","r",stdin);<br>// freopen("key.txt","w",stdout);<br>  int n,m;<br>  int a[12];<br>  int time=0;<br>  while(cin>>n>>m)<br>  {<br>int i,j;<br>double k;<br>memset(a,0,sizeof(a));<br>time++;<br>double sum=0.0;<br>double temp=0.0;<br>for(i=0;i<m;i++)<br>{<br>cin>>a[i];<br>sum+=a[i];<br>}<br>sum/=n;<br>sort(a,a+2*n);//????a[0]????a[2n-1] <br>for(j=0;j<n;j++)<br>{<br>k=a[j]+a[2*n-j-1]-sum;<br>if(k>0)<br>        temp+=k;<br>    else<br>     temp-=k;<br>    }<br>    cout<<"Set #"<<time<<endl;<br>        cout<<"IMBALANCE = "<<fixed<<setprecision(5)<<temp<<endl<<endl;<br>  }<br><br>  //system("PAUSE");<br>  return   0;<br>  }<br>1錛岃璁″埌鍑忔硶娉ㄦ剰鏄惁鏄痙ouble綾誨瀷<br>2錛岃涓嶈緇濆鍊鹼紝abs(),include<math.h><br>3,cout<<fixed<<setprecision(5)鑳戒繚闅滃皬鏁扮偣鍚庢湁錛?錛夊嚑浣嶅皬鏁? <img src ="http://www.shnenglu.com/luyulaile/aggbug/88970.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2009-07-01 10:54 <a href="http://www.shnenglu.com/luyulaile/archive/2009/07/01/88970.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.west126.cn" target="_blank">久久综合国产乱子伦精品免费</a>| <a href="http://www.metropolojinjianghotel.cn www.dr-knoell-consult.com.cn www.starlight-caraccessories.cn " target="_blank">日韩精品久久久久久</a>| <a href="http://www.30ww.cn" target="_blank">国产精品免费久久久久电影网</a>| <a href="http://www.douyinyutang.cn" target="_blank">久久精品国产亚洲AV高清热</a>| <a href="http://www.gameforpeace.cn" target="_blank">99久久国产热无码精品免费 </a>| <a href="http://www.shhuguang.com.cn" target="_blank">久久综合给合久久狠狠狠97色69 </a>| <a href="http://www.uhqw.cn" target="_blank">97久久精品人人做人人爽</a>| <a href="http://www.111net.org.cn" target="_blank">91秦先生久久久久久久</a>| <a href="http://www.bao5888.cn" target="_blank">久久一区二区三区免费</a>| <a href="http://www.zfam.cn" target="_blank">日韩人妻无码一区二区三区久久</a>| <a href="http://www.ahbbmj.cn" target="_blank">青草影院天堂男人久久</a>| <a href="http://www.qcbijj.cn" target="_blank">久久人人爽人人爽人人片AV不 </a>| <a href="http://www.gnjb.net.cn" target="_blank">69久久夜色精品国产69</a>| <a href="http://www.yylsax.cn" target="_blank">久久久久国产一区二区</a>| <a href="http://www.icaew.com.cn" target="_blank">人妻精品久久久久中文字幕一冢本</a>| <a href="http://www.fzcxpc.cn" target="_blank">久久精品国产亚洲沈樵</a>| <a href="http://www.reyouxi.cn" target="_blank">国产亚洲精品久久久久秋霞</a>| <a href="http://www.vbpt.cn" target="_blank">国产叼嘿久久精品久久</a>| <a href="http://www.jimoge.cn" target="_blank">国产精品无码久久久久久</a>| <a href="http://www.xzij.cn" target="_blank">中文字幕无码久久精品青草 </a>| <a href="http://www.xiangxiangren.cn" target="_blank">久久这里的只有是精品23</a>| <a href="http://www.lftdly.cn" target="_blank">99国产精品久久久久久久成人热</a>| <a href="http://www.t6s.com.cn" target="_blank">伊人久久大香线蕉综合热线</a>| <a href="http://www.sms321.cn" target="_blank">色综合久久88色综合天天 </a>| <a href="http://www.lbyk.com.cn" target="_blank">国内精品久久久久久久久电影网 </a>| <a href="http://www.arnerbank.cn" target="_blank">久久乐国产综合亚洲精品</a>| <a href="http://www.0769zc.net.cn" target="_blank">欧美日韩中文字幕久久伊人</a>| <a href="http://www.or-z.cn" target="_blank">亚洲国产精品无码久久</a>| <a href="http://www.t0oal.cn" target="_blank">久久久久人妻一区二区三区</a>| <a href="http://www.alexa178.cn" target="_blank">久久夜色撩人精品国产</a>| <a href="http://www.rhtyyls.cn" target="_blank">久久久精品久久久久久 </a>| <a href="http://www.yeziseo.cn" target="_blank">久久久久一级精品亚洲国产成人综合AV区 </a>| <a href="http://www.gu88.org.cn" target="_blank">久久超碰97人人做人人爱</a>| <a href="http://www.qhd33.cn" target="_blank">久久久久人妻一区二区三区 </a>| <a href="http://www.ndgbsz.cn" target="_blank">久久99久久99精品免视看动漫</a>| <a href="http://www.208dj.cn" target="_blank">2020国产成人久久精品</a>| <a href="http://www.jrtz232.cn" target="_blank">亚洲国产成人久久综合一区77</a>| <a href="http://www.onlinehotel.com.cn" target="_blank">国产精品99久久久久久宅男 </a>| <a href="http://www.kxw1.cn" target="_blank">国产美女亚洲精品久久久综合</a>| <a href="http://www.jh942.cn" target="_blank">久久综合九色欧美综合狠狠 </a>| <a href="http://www.52zx45.cn" target="_blank">人妻无码αv中文字幕久久琪琪布</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>