Time of Update: 2015-06-26
標籤:#include <stdio.h>typedef struct listnode { int f; struct listnode *next;} ListNode;ListNode *sort(ListNode *head){ ListNode *p,*p1,*p2,*p3; ListNode h, t; if (head == NULL) return NULL; h.next=head; p=&h; while (
Time of Update: 2015-06-26
標籤:C. Mail StampsTime Limit: 20 SecMemory Limit: 256 MB題目串連http://codeforces.com/problemset/problem/29/CDescriptionOne day Bob got a letter in an envelope. Bob knows that when Berland‘s post officers send a letter directly from city «A»
Time of Update: 2015-06-26
標籤:c++運算子多載包括:雙目運算子多載、單目運算子多載、流運算子多載、轉換建構函式、類型轉換函式重載運算子的函數一般格式如下: 函數類型 operator 運算子名稱 (形參表列) { // 對運算子的重載處理 }1. 雙目運算子多載雙目:有2個運算元的運算子 重載函數可以為類成員函數或者是類的友元函數: - 當是成員函數時,有一個隱藏參數(當前類),因此只有一個顯示參數:如 Complex operator+(const Complex
Time of Update: 2015-06-26
標籤:寧以pass-by-reference-to-const替換pass-by-value本節,我們一起來探究一下值傳遞和引用傳遞之間的區別。 先看一段代碼:class Person{public: Person(); virtual ~Person(); ……private: std::string name; std::string address;};class Student:public Person{public: Student(); ~
Time of Update: 2015-06-26
標籤:在看《Cplusplus Concurrency In Action Practical Multithreading》當遇到第一個樣品:#include<iostream>#include<thread>void hello(){std::cout<<"hello concurrent world\n";}int main(){std::thread
Time of Update: 2015-06-26
標籤:1. 由於前自增和後自增操作符都是一元運算子,因此重載時通過在後自增中加一個int型參數(啞元參數)加以區分,當後自增被調用時,編譯器自動在為該參數指定一個0值。2. 前自增操作符返回調用它的對象的引用,後自增操作符返回const 臨時對象3. 由於前自增是返回的是原對象的引用,因而可以執行類似於++++a這樣的式子;
Time of Update: 2015-06-26
標籤:1. 內建的&&和||操作符有"短路求值"的特性。對於&&如果第一個運算元為真,那麼&&即返回為真,不再對第二個運算元進行求值,||則相反,利用這個特性可以寫出下面的代碼:char *p;...if(p>0&&strlen(p)>10)...View
Time of Update: 2015-06-26
標籤:1. C++ 允許內建資料類型之間(例如char和int,int和double等)進行隱式轉換,對於內建類型之間的隱式轉換有詳細的規則,但不管怎樣,這些都是語言提供的,既相對安全,我們又無法更改(也就是說,這些我們不用管也管不著); 對於自訂的類類型,隱式轉換可以通過帶單一自變數的建構函式和隱式類型轉換操作符來實現(所謂"單一自變數指的是可以有多個參數,但除了第一個參數其他參數必須有預設實參)2.
Time of Update: 2015-06-26
標籤://線索二叉樹,這裡在二叉樹的基礎上添加了線索化//楊鑫#include <stdio.h>#include <stdlib.h>typedef char ElemType; typedef enum {Link,Thread} childTag; //Link表示結點,Thread表示線索typedef struct bitNode{ ElemType data; struct bitNode *lchild, *rchild; int ltag,
Time of Update: 2015-06-26
標籤: 引子 “請寫一個Singleton。”面試官微笑著和我說。 “這可真簡單。”我心裡想著,並在白板上寫下了下面的Singleton實現: 1 class Singleton 2 { 3 public: 4 static Singleton& Instance() 5 { 6 static Singleton singleton; 7 return singleton; 8
Time of Update: 2015-06-26
標籤:c++記憶體分布 c++對象記憶體分布 c++私人虛函數 1.前言本篇文章的所有代碼例子,如果是windows上編譯運行,則使用的是visual studio 2013。如果是RHEL6.5平台(linux kernal: 2.6.32-431.el6.i686)上編譯運行,則其gcc版本為4.4.7,如下所示:[[email protected] ~]# gcc
Time of Update: 2015-06-26
標籤: 昨天面試了2家公司,加上上個月28號面試的題目,有幾道題目沒有做對,在這裡總結一下,避免下次犯同樣的錯誤。首先是綜合題:1. -1,2,7,28, ,126 解:63 它們的規律是:0的三次方減1=-11的三次方加1=22的三次方減1=73的三次方加1=284的三次方減1=635的三次方加1=126……n^3+(-1)^n 2.
Time of Update: 2015-06-26
標籤:之前一直只是知道有這麼個參數修飾符,也知道用來幹嘛的,但是基本就沒用上。這幾天好好整理了一下,發現ref的修飾符可以協助簡化很多代碼。讓我更深入的瞭解到物件導向的深沉含義。自訂一個類中,類中的方法形式參數帶上ref參數後,封裝好。在其他類中引用時。其他類傳入ref的實參後,不僅能夠直接進行方法的運算,還能直接通過此實參判斷該資料的變化情況。。好處: 封裝的類往往只能return一個參數 除非寫上數組等 ,但是這樣做煩瑣複雜。使用ref簡化代碼。
Time of Update: 2015-06-26
標籤: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace notifyIconShow{ public partial class ColdJoke
Time of Update: 2015-06-26
標籤:用例: 現在有一個命名空間為Device的Device.dll檔案,它含兩個類Device1和Device2;現通過反射原理建立Device1和Device2類,具體語句如下: //1、首先需要添加引用 using System.Reflection; //2、建立Device1 &
Time of Update: 2015-06-26
標籤:c# json 序列化 還原序列化 public class JsonSerializer { /// <summary> /// json序列化 /// </summary> /// <typeparam
Time of Update: 2015-06-26
標籤:c# 實體類 序列化 還原序列化 /// <summary> /// 實體類序列化的還原序列化的類 /// </summary> /// <typeparam name="T"></typeparam> public abstract class
Time of Update: 2015-06-26
標籤:2.1
Time of Update: 2015-06-26
標籤: int[] b = { 1, 2, 3, 4, 5 }; int max; int min; int sum; int avg; OutTest(b,out max,out min,out sum,out avg);
Time of Update: 2015-06-26
標籤:C. StripeTime Limit: 20 SecMemory Limit: 256 MB題目串連http://codeforces.com/problemset/problem/18/CDescriptionOnce Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly