Time of Update: 2018-12-04
之前寫過一個二叉尋找樹,其中最麻煩的是刪除元素的方法,一共分了8種情況,主要是要區分是否是根節點和非根節點,寫的太煩了,詳細請參見:http://blog.csdn.net/todd911/article/details/8471566今天要來簡化一下這個方法,之前我還寫過一篇《簡潔的單項鏈表插入操作》,利用雙指標,簡化了根節點和非根節點的區別,詳細請參見:http://blog.csdn.net/todd911/article/details/8941593,其實在二叉尋找樹中也可以使用這種方
Time of Update: 2018-12-04
輸入輸出函數家族家族名 目的 可用於所有的流 只用於stdin和stdout getchar 字元輸入 fgetc,getc getcharputchar 字元輸出 fputc,putc
Time of Update: 2018-12-04
#include <stdio.h>#include <malloc.h>int main(void){ int *p; int *a; a = (int*)malloc(sizeof*p); *a=1; printf("%d\n",*a); free(a); return 0;}上面這段代碼,編譯運行都沒有任何問題。a =
Time of Update: 2018-12-04
將數組放到結構體中,直接使用“=”就能將數組中的值全部拷貝到其他相同類型的數組中。#include <stdio.h>struct array_tag{ int a[10];};int main(void){ struct array_tag m = {{1,2,3,4,5,6,7,8,9,0}}; int i; for(i=0;i<10;i++){ printf("%d ",m.a[i]);
Time of Update: 2018-12-04
方法一:#include <stdio.h>#define PRINT(FORMAT,VALUE) \ printf("the value is "FORMAT"\n",VALUE);int main(void){ int x = 6; PRINT("%d",x+2); return 0;}運行結果:the value is 8方法二:#include <stdio.h>#define
Time of Update: 2018-12-04
這是由我“無中生有”引起的問題,記錄下來或許對大家有協助。 我們的一個測試程式是用C#寫的,它會讀取一個設定檔,設定檔裡包含串口的設定或者網路IP/連接埠的設定。 我有一次淡疼的把這個程式改為了“Windows 2000相容模式”,在後來的使用中便發現這個程式無法正確解析設定檔。 具體原因已經超出我的能力範圍。我想和XP相容模式下對於程式運行環境的差異有關。 在native的XP下,程式有足夠的許可權訪問或申請它需要的資源;而Windows 2000相容模式下,作業系統為程式的運行“
Time of Update: 2018-12-04
#include <iostream> using namespace std;struct student{ char name[30]; int age; struct student *next;};int main(){ struct student st1, st2, *head, *p; strcpy(st1.name, "張三"); st1.age = 20; strcpy(st2.name, "李四"); st2
Time of Update: 2018-12-04
今天為了徹底搞定一個關於c中數組初始化和聲明不同情況下,比如只聲明一個數組char str[20];那麼這str裡面是什麼內容呢?我用vc6++,debug下看到都是-56餓asc碼,後來請教了一個華為的大牛,他說 按照理論來說裡面的內容都是有可能的,這和叫做“髒記憶體”或者叫做“野數組”。好了第一個問題搞懂了。 第二個問題
Time of Update: 2018-12-04
1:類似junit的斷言,只是在assert中的斷言,如果不滿足的話就程式退出。比如#include <assert.h>int main(void){ assert(6 < 5); system("pause"); return 0;}在執行到assert(6 < 5);的時候因為不滿足斷言,於是程式退出。如果不想讓assert(6 < 5)起作用,就在最上面添加宏定義#define NDEBUG要添加在#include
Time of Update: 2018-12-04
數組賦值我總結一下吧也就三種,那char的來舉例: 定義的時候直接賦值.1:char a[20] = "Hello World!"; 2: char a[20]; strcpy(a, "Hello World!"); 3:char a[20] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!'}; 常見錯誤賦值方式: 1:char a[20]; a = "Hello
Time of Update: 2018-12-04
今天效率需要,需要搞定一個多線程的程式,今天我用的關鍵字是Monitor.Enter(this);和Monitor.Exit(this);來說一下到底鎖的是什麼,之前對java中的同步關鍵字理解的應該還算可以,鎖的時候永遠鎖的是對象,所以也只有這些線程是在這個物件範圍內操作,並且遇到這個關鍵字才能起到同步的效果。先來一個同步起作用的例子,然後再來一個相反的例子來找個反面典型。 using System;using System.Collections.Generic;using System.
Time of Update: 2018-12-04
今天學java,裝了jdk6,用editplus配置了下環境,在看網易的視頻時,留心了下自加操作的區別.C++ 編譯器:Dev-cpp 4.9.9.2C++程式:#include<iostream>using namespace std;int main(){ int i=3; int count; count=(i++)+(i++)+(i++); cout << i << endl << count; system(
Time of Update: 2018-12-04
將人民幣的數字表示轉化成大寫表示(C#版) chenyu001 [收藏] 關鍵字 .net出處 將人民幣的數字表示轉化成大寫表示(C#版) 實在沒有什麼好講的,就是一個方法,大家拿去用吧using System;namespace Test.Com{ /// <summary> /// 功能:字串處理函數集 /// </summary> public class
Time of Update: 2018-12-04
使用反射FileInfo file=new FileInfo(Path.Combine(Application.StartupPath,@"C:/Documents and Settings/greatsft/案頭/test/Testdll/bin/Debug/Testdll.dll")); if(file.Exists) { try { Assembly ass=Assembly.LoadFrom(file.FullName); Type[]
Time of Update: 2018-12-04
(一)INIFile.cs using System;using System.Runtime.InteropServices;using System.Text;namespace CreateWebDir{ /// <summary> /// INIFile 的摘要說明。 /// </summary> public class INIFile { public string path; public INIFile(string
Time of Update: 2018-12-04
System.IO.FileStream fs=new System.IO.FileStream(lstFile.Text,System.IO.FileMode.Open,System.IO.FileAccess.Read); long lngPos=fs.Seek(-128,System.IO.SeekOrigin.End); byte[] bInfo=new
Time of Update: 2018-12-04
object missing = System.Reflection.Missing.Value;object savech=WdSaveOptions.wdDoNotSaveChanges ;mydoc=wordApp.Documents.Open(ref myobj,ref missing,ref myfalse,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref
Time of Update: 2018-12-04
1.XmlString轉化成實體類對象XmlString轉化成實體類對象即XML的解析並給實體類賦值。比如,將XMl解析並產生Cost實體類:public static object GetCosts(string xmlString) { Model.COSTS myCosts = new COSTS(); //Xml解析 XmlDocument doc = new XmlDocument();
Time of Update: 2018-12-04
1. 今天寫程式,寫了這樣一行代碼:char * pArr[10] = new char[20]; 後來發現這樣寫是不對的。= 號左邊是char** 類型的,右邊是char*類型的,不可以賦值的。也不可以這樣寫: char * pArr[10]={new char[20]}; 這樣只是對數組裡的第一個元素裡的指標初始化了記憶體地區,其他9個元素沒有被分配記憶體。這裡可以在花括弧裡寫10個“new
Time of Update: 2018-12-04
驚豔的效果還在繼續,第二章開始講到了一些基本的傳統的(但是我居然還是不知道的)技法,利用模板的編譯特殊編譯特性帶來了些新的協助。有印象的東西就是Compile-time assertions,