Time of Update: 2018-12-08
代碼如下所示:複製代碼 代碼如下:#include "stdafx.h"#include <string>#include <iostream>using namespace std;char* strcpy(char *src_str, char *dest_str){ char* dest = dest_str; if ((src_str == NULL)||(dest_str == NULL)) //檢查指標有效性 { throw "Invalid
Time of Update: 2018-12-08
1 . 用同一個類的來源物件構造一個目標對象時,會調用拷貝建構函式來構造目標對象,如果沒有定義拷貝建構函式,將調用類的預設拷貝函數來構造目標對象。2 . 當一個函數的傳回值為一個類的對象時,如果在調用函數中,沒有定義一個對象來接收這個返回對象值,會用返回一個臨時對象儲存返回對象的值。在被調用函數結束時,這個臨時對象被銷毀。而當調用函數中有一個接受對象時,就將返回對象賦值給接收對象,這個返回對象在調用函數結束時調用解構函式。3.
Time of Update: 2018-12-08
代碼如下所示:複製代碼 代碼如下:/* * 冒泡排序 */void BubbleSort(int arr[], int n){ int temp; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (arr[i] > arr[j]) { temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } }}/* *
Time of Update: 2018-12-08
個人實現例子:複製代碼 代碼如下:#include <stdio.h>#include <string.h>#define M 4int add(int a, int b);int sub(int a, int b);int mul(int a, int b);int div(int a, int b);int (*oper_func[])(int, int) = { add, sub, mul, div};char oper_sequence[M][10] = {
Time of Update: 2018-12-08
在項目開發工程中,如果能確定哪個檔案下的哪個函數下的哪行出錯--即鎖定錯誤,那該多好啊,該文章就是為此而作的。首先來瞭解一下檔案預設的輸出資訊的函數吧:檔案資訊函數:複製代碼 代碼如下:printf("line : %d\n", __LINE__); //當前行數printf("filename : %s\n", __FILE__); //當前檔案名稱printf("function : %s\n", __FUNCTION__); /
Time of Update: 2018-12-08
上一篇文章<用C語言實現單鏈表的各種操作(一)>主要是單鏈表的一些最基本的操作,下面,主要是一些其他的典型的演算法和測試程式。 複製代碼 代碼如下:/* 對單鏈表進行排序處理*/struct LNode *sort(struct LNode *head){ LinkList *p; int n,i,j; int temp; n = ListLength(head); if(head == NULL || head->next == NULL) return
Time of Update: 2018-12-08
《代碼大全》建議在變數定義的時候進行初始化,但是很多人,特別是新人對結構體或者結構體數組定義是一般不會初始化,或者不知道怎麼初始化。1、初始化複製代碼 代碼如下:typedef struct _TEST_T { int i; char c[10];}TEST_T;TEST_T gst = {1, “12345”};//可以初始化,設定i為1,s為一個字串.TEST_T gst = {1};//初始化個數少於實際個數時,只初始化前面的成員。TEST_Tgst =
Time of Update: 2018-12-08
C#字串常見操作總結詳解(1)取字串長度 <string>.Length;(2)字串轉為位元碼 GetBytes(<string>)(3)字串相加 推薦StringBuilder sb = new StringBuilder();sb.Append(<string>);(4)截斷字串的一部分 變數.SubString(起始位置,截取位元);(5)查指定位置是否為空白字元 char.IsWhiteSpace(字串變數,位元);(6)
Time of Update: 2018-12-08
各位親們可以嘗試以下代碼:註:這裡我就只有一個html標籤對來說明問題了,首部之類的東西,自己添加。複製代碼 代碼如下:<html> <head> <title>網頁中動態顯示系統日期時間</title> <script language="JavaScript"> function startTime() { var today =
Time of Update: 2018-12-08
一個代碼:複製代碼 代碼如下:#include<stdio.h>#include<stdlib.h>#define uchar unsigned char#define uint unsigned intvoid display(uchar *p);char h[4] = {'A','B','C','\0'};char e[4] = {'E','F','L','\0'};char l[4] = {'M','N','O','\0'};char o[4] = {'X','Y'
Time of Update: 2018-12-08
建立類Product:複製代碼 代碼如下:class Product{ public string name; public int Id { get; set; } public void ShowProduct() { Console.WriteLine("Id={0} ,Name={1}", Id, name); }}Main方法代碼如下:複製代碼 代碼如下:static void Main(string[] args){
Time of Update: 2018-12-08
以前在CodeProject上看到了一篇文章:MBG Extensions Library 大致是作者在介紹自己寫的擴充方法類庫,內容如下:In()複製代碼 代碼如下:if (myString == "val1" || myString == "val2" || myString == "val3" || myString == "val4" || myString == "val5") { //Do something
Time of Update: 2018-12-08
我們知道C#中 a=b=c;是合法的,例如:int i,j,k;i=j=k=1;下面有兩道題:第一題:複製代碼 代碼如下: const int x=1; short y; object z; z=y=x; //請問下面的輸出是什麼? Console.WriteLine(z.GetType().ToString());第二題:複製代碼 代碼如下:class C { private string x; public string X {
Time of Update: 2018-12-08
c++中的來源程式:複製代碼 代碼如下:class X {private: int i;};int main() { X x;}上面的類X沒有定義建構函式,僅僅有一個int i。下面為其組譯工具:複製代碼 代碼如下:; 7 : int main() { push ebp;ebp為一個寄存器,總是指向一個函數呼叫堆疊的棧底,作為基址,用位移量來訪問該調用棧上的變數,但這裡沒有任何變數要訪問,因此不起作用 mov ebp,
Time of Update: 2018-12-08
StringDictionary:預設key不區分大小寫 NameValueCollection:預設key區分大小寫 KeyedCollection:不是索引值對容器,但是比索引值對容器更好用,強烈推薦命名空間using System.Collections.SpecializedSystem.Collections 命名空間包含介面和類,這些介面和類定義各種對象(如列表、隊列、位元組、雜湊表和字典)的集合。 System.Collections.Generic
Time of Update: 2018-12-08
複製代碼 代碼如下:static string GetStr(string s = "a", int i = 10, string r = "rrrr") { return s + i + r; }調用時,可以用如下幾種方法調用複製代碼 代碼如下: GetStr(); GetStr("abcde"); GetStr("abcde", 100);
Time of Update: 2018-12-08
複製代碼 代碼如下: private void button2_Click(object sender, EventArgs e) { // Create a request for the URL. WebRequest request = WebRequest.Create("http://www.baidu.com/"); // If required by the
Time of Update: 2018-12-08
儘管這個概念已經讓人說濫了 ,還是想簡單記錄一下, 以備以後查詢。複製代碼 代碼如下:#ifdef _DEBUG#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)#else#define DEBUG_CLIENTBLOCK#endif#define _CRTDBG_MAP_ALLOC#include <crtdbg.h>#ifdef _DEBUG#define new
Time of Update: 2018-12-08
複製代碼 代碼如下://調用API [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, ExactSpelling = true)] public static extern IntPtr GetForegroundWindow(); //獲得本表單的控制代碼
Time of Update: 2018-12-08
之前看了很多關於圖的遍曆的代碼 今天我用了常用的資料結構寫出來 純屬於演算法 性方面還有待提高 時間複雜度最壞情況下O(2^n) 最優:O(n^2)線路圖為雙向 帶有權值 比如A-B距離是5000km 那麼B-A有可能不是5000km 所以我在LoadData方法時候沒做交換變數直接存放在集合裡面以起點遞迴尋找下一連接點並返回當作起點節點尋找 代碼雖然有些亂 本想調整 !複製代碼 代碼如下: static List<string[]> maindata = null;