Time of Update: 2018-12-05
C語言中的多維陣列是不能完全做為參數來使用的,因為它是受限制的:/*=====================================本程式是為了學習而使用的的測試程式,用來說明C語言中的一些學習誤區,對C語言的某些知識作詳細的講解=======================================*/#include <stdio.h>#include <stdlib.h>void fun1(int m[2][3]){ printf("第一個測試值為:
Time of Update: 2018-12-05
單鏈表的翻轉是面試中經常出現的面試題,下面是採用倒插法實現的代碼:struct node* reverse(struct node *head){ struct node *pReversedHead, *qUnReversedHead, *rTmp; pReversedHead = NULL; qUnReversedHead = head; while(qUnReversedHead){ rTmp = qUnReversedHead-&
Time of Update: 2018-12-05
在WinForms編程中,我們經常會用到UserControl或者編寫自己的Control,但是,當我們為Control定義一個屬性的時候,不希望控制項的使用者通過設計器對控制項的該屬性進行賦值。更顯而易見的一個問題是,設計器會為該屬性產生預設的賦值代碼,有時候,這樣的賦值代碼會導致該控制項以及使用了該控制項的其他控制項或視窗無法在設計器中開啟。這個時候,給該屬性加上Browsable和DesignerSerializationVisibility屬性就可以解決這個問題。範例程式碼如下:
Time of Update: 2018-12-05
Technorati 標籤: 子網路遮罩,網路子網路遮罩與網路地址合法的廣播位址就是主機的網路地址加上最大的主機號。網路地址通過機器的ip地址與子網路遮罩按位與得出,我們以ip地址為10.78.202.175 子網路遮罩為255.255.255.0為例來分析一下上面的幾個概念問題1:子網路遮罩為255.255.255.0的子網內可以有多少台主機IP首先將這兩個東西換算成二進位代碼ip地址:00001010.01001110.11001010.10101111子網路遮罩:11111111.1111
Time of Update: 2018-12-05
#include <iostream>#include <cmath>using namespace std;const int N = 8;int a[N + 1];int counts;void nqueen(int);bool constraints(int k);void backtrack(int k,int n);int main(){nqueen(N);cout << counts * 2 << endl;system("PAUSE"
Time of Update: 2018-12-05
這個題目是編程之美上出現的,今年在幾個公司筆試的時候都出現了這個題目,之前一直以為 直接用 N / 5 就是結果,昨天被馬鈴薯面試的時候,才發現自己理解錯了,思路是這樣的,0 的個數就是 1,,2,...,n中n個數中能夠分解出5的因子的個數。之前以為 5,10,20,..., n/5 * 5 總共有 n/5個能夠提出5的因子的,但是顯然這裡出現了問題,對於 25 這個數 = 5^2 能提出兩個5的因子,所以應該會產生兩個0。那我們該怎麼解決這個問題呢,我們將5,10,20,....,
Time of Update: 2018-12-05
思路:這一類問題主要是考慮你的思路,演算法本身應該並沒有什麼實際的應用(鄙人見少視淺,如果有具體的應用的地方,歡迎各位指出),其實這類問題之前也遇到過,如某機率產生器以p和1-p產生A,B,怎麼構造出0.5的機率產生器。p和1-p怎麼才能產生相等的關係呢,其實,我們知道p*(1-p) = (1-p)*p
Time of Update: 2018-12-05
class Puzzle: Size = 9 N = 81 Nums = {1,2,3,4,5,6,7,8,9} IndexToBox = [0,0,0,1,1,1,2,2,2,0,0,0,1,1,1,2,2,2,0,0,0,1,1,1,2,2,2, 3,3,3,4,4,4,5,5,5,3,3,3,4,4,4,5,5,5,3,3,3,4,4,4,5,5,5, 6,6,6,7,7,7,8,8,8,6,6,6
Time of Update: 2018-12-05
統計一個檔案中特定字元的個數統計一個檔案中某個字串的個數,其實就是在在一塊沙地裡面找石頭,有的人看到石頭以後,在上面做個標記(grep),然後記住自己做了多少個標記;有的人看到石頭以後,把它挖了(tr),最後統計自己挖了多少石頭;有的人看到石頭以後,把它跳過去(awk),然後統計自己跳了多少次。這是我用的的檔案[code][root@bzhou test]# cat file hafsdhahahafsdfsdhahahaha[/code]我想匹配的是‘haha’這個字串1.grep的-o選項[
Time of Update: 2018-12-05
#include#include#include#include#include#define TRUE 1#define FALSE 0#define Stack_Size 50typedef struct{int elem[Stack_Size];int top;}SeqStack;int Match(char a,char b){if((a=='{' && b=='}')||(a=='(' && b==')')||(a=='[' && b==
Time of Update: 2018-12-05
題目:假設一整型數組存在若干正數和負數,現在通過某種演算法使得該數組的所有負數在正數的左邊,且保證負數間和正數間元素相對位置不變。時空複雜度要求分別為:o(n),o(1)例如 -3 4 2 -1 7 3 -5 排序後 -3 -1 -5 4 2 7 3
Time of Update: 2018-12-05
// 找數組中唯一出現2次的數.cpp : Defines the entry point for the console application.///*假設你有一個用1001個整數組成的數組,這些整數是任意排列的,但是你知道所有的整數都在1到1000(包括1000)之間。此外,除一個數字出現兩次外,其他所有數字只出現一次。假設你只能對這個數組做一次處理,用一種演算法找出重複的那個數字。如果你在運算中使用了輔助的儲存方式,那麼你能找到不用這種方式的演算法嗎?1001個數異或結果與1-1000
Time of Update: 2018-12-05
The bag-of-words model is a simplifying assumption used in natural language processing and information retrieval. In this model, a text (such as a sentence or a document) is represented as an unordered collection of words, disregarding grammar
Time of Update: 2018-12-05
http://acm.pku.edu.cn/JudgeOnline/problem?id=1611 Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best
Time of Update: 2018-12-05
這個問題,貌似很簡單,但要回答好,卻不是那麼簡單。以下總結下怎麼回答這個問題。step 1:解釋進程和線程的概念 進程:a process is an instance of a computer program that is being executed. A computer program is a passive collection of instructions; a process is the actual execution of those instructions.
Time of Update: 2018-12-05
實現這個資料結構主要有三個函數:如下:void UFset() //初始化{for(int i=0;i<N;i++) parent[i]=-1;}int Find(int x) //返回第X節點所屬集合的根結點{for(int i=x;parent[i]>=0;i=parent[i]);while(i!=x) //最佳化方案――壓縮路徑{ int tmp=parent[x]; parent[x]=i; x=tmp;}return i;}void
Time of Update: 2018-12-05
ARM+LINUX路線,主攻嵌入式Linux作業系統及其上應用軟體開發目標: (1)掌握主流嵌入式微處理器的結構與原理(初步定為arm9) (2)必須掌握一個嵌入式作業系統 (初步定為uclinux或linux,版本待定) (3)必須熟悉嵌入式軟體開發流程並至少做一個嵌入式軟體項目。 從事嵌入式軟體開發的好處是: (1)目前國內外這方面的人都很稀缺。這一領域入門門檻較高,所以非專業IT人員很難切入這一領域;另一方面,是因為這一領域較新,目前發展太快,大多數人無條件接觸。
Time of Update: 2018-12-05
假設給定一顆樹節點的結構:struct node { int data; struct node *left; struct node *right;}typedef strcut node *tree叫你寫出遞迴遍曆樹結構的代碼,其實很簡單中序遍曆如下:void traverse(tree T, (*visit)(int)){ if (!T) { traverse(T->left,visit);
Time of Update: 2018-12-05
以前在《The c programming language》 裡面看到了個尾碼計算機,輸入是尾碼運算式,輸出計算結果。當時還不知道如何把使用者容易使用的運算式(中綴)轉換成尾碼。後來看了《Data structures and algorithm analysis》,發現 棧
Time of Update: 2018-12-05
以前發現王曉東那本書上產生全排的演算法並不太好。書中代碼如下:#include <iostream>using namespace std;template <class Type>inline void Swap(Type &a,Type &b){ Type temp=a;a=b;b=temp;}template <class Type>void Perm(Type list[],int k,int m){ if(k==m)