Time of Update: 2018-12-07
今天看程式員面試寶典發現了一個問題。在P37的例子中,寶典認為>>比~的優先順序高。這是錯誤的。實際上~比>>的優先順序高。程式碼如下: #include <iostream>using namespace std;int main(){ unsigned char a=0xA5; unsigned char b=~a>>4; printf("b=%d\n",b); system("PAUSE");
Time of Update: 2018-12-07
靜態建構函式用於初始化任何待用資料,或用於執行僅需執行一次的特定操作。在建立第一個執行個體或引用任何靜態成員之前,將自動調用靜態建構函式。Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class SimpleClass{ // Static constructor static SimpleClass() { //
Time of Update: 2018-12-07
C#數字類型的資料包括decimal, double和 float。以前學過現在忘得都差不多了,現在簡單的複習一下。 根據MSDN的解釋,decimal類型是128位的浮點數,資料範圍是±1.0 × 10−28 to ±7.9 × 1028,精度在28-29位有效數字,在一個數字後面加m或M代表它是decimal類型。double類型是64位的浮點數,資料範圍是±5.0 × 10−324 to ±1.7 × 10308,精度在15-16位有效數字,在一個數字後面加d或D代表它是double類型。
Time of Update: 2018-12-07
c#中分割字串的方法第一種方法:開啟vs.net建立一個控制台項目。然後在Main()方法下輸入下面的程式。 string s="abcdeabcdeabcde"; string[] sArray=s.Split(''c''); foreach(string i in sArray) Console.WriteLine(i.ToString()); 輸出下面的結果:ab deab
Time of Update: 2018-12-07
C#讀取文字檔 今天一個學生問我如何從一個文本中讀取內容,如下是做的是控制台中的例子,在別的地方也是這個道理。 // 讀操作 public static void Read() { // 讀取檔案的源路徑及其讀取流 string strReadFilePath = @"../../data/ReadLog.txt"; StreamReader srReadFile = new
Time of Update: 2018-12-07
C 編程中相關檔案尾碼 .a 靜態庫 (archive) .c C原始碼(需要編譯預先處理) .h C原始碼標頭檔 .i C原始碼(不需編譯預先處理) .o 對象檔案 .s 組合語言代碼 .so 動態庫 單個源檔案產生可執行程式 下面是一個簡單的“hello, ubuntu”程式的原始碼: /* helloubuntu.c */#include <stdio.h>int main(int argc,char *argv[]){ printf(“hello, ubuntu/n”);
Time of Update: 2018-12-07
應用情境:在軟體系統中,經常有這樣一些特殊的類,必須保證它們在系統中只存在一個執行個體,才能確保它們的邏輯正確性、以及良好的效率。 這是類設計者的責任,而不是使用者的責任。 保證一個類僅有一個執行個體,並提供一個該執行個體的全域訪問點。 ——《設計模式》GoF 代碼實現如下://單線程Singleton樣本: public class Singleton { private static Singleton instance;
Time of Update: 2018-12-07
學習、研究庫函數的實現,能使你考慮問題更加嚴謹、全面,培養良好的編程風格和習慣最近想學習一下C語言庫函數的內部實現,於是自己簡單地寫了幾個貼出以下代碼,希望大家能夠幫忙指正、最佳化、完善,特別是考慮不周和執行效率上給出指導意見閱讀本文前,可以先參考本部落格的上一篇文章 C語言函數小集合 調試環境:VS2008(C)// sysFunc.cpp : Defines the entry point for the console application.//#include
Time of Update: 2018-12-07
1 #include <stdio.h> 2 3 int main() 4 { 5 int c,m,n,l; 6 m=n=l=0; 7 /* m代表空格個數,n代表定位字元個數,l代表分行符號個數 */ 8 int flag=0;//表示是否遇到分行符號 9 while((c = getchar()) != EOF)10 {11 if(c == '\n')12 {13 ++l;
Time of Update: 2018-12-07
C#非同步編程有四種方式,可參考下面的文章MSDN-非同步編程概述 [C#] 並且在MSDN協助文檔中也有相關介紹MSDN:ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpgenref/html/cpconasynchronousexecution.htm 另外這樣也可以實現相同的效果(我還沒有使用過): //System.Threading.ThreadPool.QueueUserWorkItem(new
Time of Update: 2018-12-07
string不變 stringbuilder可變C#語言還是比較常見的東西,這裡我們主要介紹C# StringBuilder和String,包括介紹大量字串拼接或頻繁對某一字串進行操作時最好使用 StringBuilder,不要使用 String等方面。C# StringBuilder和String區別String 在進行運算時(如賦值、拼接等)會產生一個新的執行個體,而 StringBuilder 則不會。所以在大量字串拼接或頻繁對某一字串進行操作時最好使用
Time of Update: 2018-12-07
今天寫了個
Time of Update: 2018-12-07
Hanoi問題.都是基本的。 1 private static void TestHanoi(int n, string X, string Y, string Z) 2 { 3 if (n <= 1) 4 { 5 Move(X, Z); 6 } 7 else 8 { 9 TestHanoi(n - 1, X
Time of Update: 2018-12-07
1.DateTime 數字型 System.DateTime currentTime=new System.DateTime(); 1.1 取當前年月日時分秒 currentTime=System.DateTime.Now; 1.2 取當前年 int 年=currentTime.Year; 1.3 取當前月 int 月=currentTime.Month; 1.4 取當前日 int 日=currentTime.Day; 1.5 取當前時 int 時=currentTime.Hour; 1.6
Time of Update: 2018-12-07
26招教你如何清理C盤下的檔案 1.開啟“我的電腦”-“工具”-“檔案夾選項”-“查看”-在“顯示所有檔案和檔案夾”選項前打勾-“確定” 2.刪除以下檔案夾中的內容: x:\Documents and Settings\使用者名稱\Cookies\下的所有檔案(保留index檔案) x:\Documents and Settings\使用者名稱\Local Settings\Temp\下的所有檔案(使用者臨時檔案) x:\Documents and
Time of Update: 2018-12-07
web.configCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><connectionStrings> <add name="i05ConnectionString1" connectionString="Data Source=localhost;Initial Catalog=i05;Integrated
Time of Update: 2018-12-07
ExceptionArgs.cs://異常資訊基類 [Serializable] public abstract class ExceptionArgs { public virtual String Message { get { return String.Empty; } } }泛型的異常類:[Serializable] public sealed class
Time of Update: 2018-12-07
在C++中,有三種類型的迴圈語句:for, while, 和do...while, 但是在一般應用中作迴圈時, 我們可能用for和while要多一些,do...while相對不受重視。 但是,最近在讀我們項目的代碼時,卻發現了do...while的一些十分聰明的用法,不是用來做迴圈,而是用作其他來提高代碼的健壯性。 1. do...while(0)消除goto語句。 通常,如果在一個函數中開始要分配一些資源,然後在中途執行過程中如果遇到錯誤則退出函數,當然,退出前先釋放資源,我們的代碼
Time of Update: 2018-12-07
1、在.NET中,繼承與語言無關,用一種託管語言編寫的類可以繼承用另一種託管語言編寫的類 跨語言繼承必須保證基類和衍生類別都遵循Common Language
Time of Update: 2018-12-07
結果圖 1 #include <stdio.h> 2 //s為初態,z為終態 3 int in(int s,int z) 4 { 5 if(s == z) 6 { 7 printf("3\nlook!the last status belongs to Z"); 8 return 1; 9 }10 else11 {12 return 0;13 }14 }15