Time of Update: 2018-12-03
我們可以用static修飾一個類的成員函數,也可以用const修飾類的成員函數(寫在函數的最後表示不能修改成員變數,不是指寫在前面表示傳回值為常量)。 請問:能不能同時用static和const修飾類的成員函數? 答案是不可以。C++編譯器在實現const的成員函數的時候為了確保該函數不能修改類的執行個體的狀態,會在函數中添加一個隱式的參數const
Time of Update: 2018-12-03
#include <iostream>using namespace std;void Bin_sort(int a[],int n){for(int i=1; i<=n; ++i){if(a[i] < a[i-1]){int temp = a[i];//折半尋找int low = 0;int high = i-1;while(low <= high){int mid = (low+high)/2;if(a[mid] > temp){high = mid-1;
Time of Update: 2018-12-03
題目(二):運行下面的代碼,輸出是什嗎?class A{};class B{public: B() {}~B() {}};class C{public: C() {} virtual ~C() {}};int _tmain(int argc, _TCHAR* argv[]){ printf("%d, %d, %d\n", sizeof(A), sizeof(B), sizeof(C)); return 0;} 答案是1, 1,
Time of Update: 2018-12-03
#include <iostream>using namespace std;void SelectionSort(int a[],int n){for(int i=0; i<n-1; ++i){int k=i;for(int j=i+1; j<n; j++){if(a[k]>a[j]){k=j;}}if(k!=i){swap(a[k],a[i]);}}}void print(int a[],int n) { for(int i=0; i<
Time of Update: 2018-12-03
//n的階乘末尾有幾個0#include <iostream>using namespace std;int count(unsigned int n){int count = 0;while(n > 0){n = n/5;count += n;}return count;}void main(){cout <<count(1024)<<endl;}是5的倍數的數有: 1024 / 5 = 204個是25的倍數的數有:1024 / 25 = 40個是12
Time of Update: 2018-12-03
Http定義了與伺服器互動的不同方法,最基本的方法有4種,分別是GET,POST,PUT,DELETE。URL全稱是資源描述符,我們可以這樣認為:一個URL地址,它用於描述一個網路上的資源,而HTTP中的GET,POST,PUT,DELETE就對應著對這個資源的查,改,增,刪4個操作。到這裡,大家應該有個大概的瞭解了,GET一般用於擷取/查詢資源資訊,而POST一般用於更新資源資訊。根據HTTP規範,GET用於資訊擷取,而且應該是安全的和等冪的。所謂安全的意味著該操作用於擷取資訊而非修改資訊。換
Time of Update: 2018-12-03
#include <iostream>using namespace std;void QuickSort(int a[],int low,int high){int i=low;int j=high;int temp=a[low];while(low < high){while(low<high && a[high]>=temp){high--;}swap(a[high],a[low]);while(low<high &&
Time of Update: 2018-12-03
#include <iostream>#include <windows.h>using namespace std;HANDLE hMutex;DWORD WINAPI Fun(LPVOID lpParamter){ while(1){WaitForSingleObject(hMutex, INFINITE);cout<<"A"<<endl; Sleep(1000);ReleaseMutex(hMutex); }return
Time of Update: 2018-12-03
基礎知識:資料查詢:select資料定義(DDL):create drop alter資料操縱(DML):insert update delete資料控制(DCL):grant
Time of Update: 2018-12-03
#include <iostream>using namespace std;void BubbleSort(int a[],int n){int i;bool change = true;while(change){change = false;for(i=0; i<n-1 ; i++){if(a[i]>a[i+1]){change = true;swap(a[i],a[i+1]);}}}}void print(int a[],int n) {
Time of Update: 2018-12-03
6,在一次事件中,明明是顧客做錯了,但顧客卻一味認為是你錯,你該怎麼做?(1)首先,我會保持冷靜。作為一名工作人員,在工作中遇到各種各樣的問題是正常的,關鍵是如何認識它,積極應對,妥善處理。(2)其次,我會反思一下客戶不滿意的原因。一是看是否是自己在解決問題上的確有考慮的不周到的地方,二是看是否是客戶不太瞭解相關的服務規定而提出超出規定的要求,三是看是否是客戶瞭解相關的規定,但是提出的要求不合理。(3)再次,根據原因採取相對的對策。如果是自己確有不周到的地方,按照服務規定作出合理的安排,並向客戶
Time of Update: 2018-12-03
#include <iostream>using namespace std;//雙向冒泡排序//雞尾酒排序void CocktailSort(int a[],int n){inti;int left=0;int right=n-1;bool
Time of Update: 2018-12-03
運行下面中的代碼,得到的結果是什嗎?class A{private: int m_value;public: A(int value) { m_value = value; } void Print1() { printf("hello world"); } void Print2() {
Time of Update: 2018-12-03
//斐波那契數列#include <iostream>using namespace std;struct matrix{//建構函式matrix(long long m00 = 0,long long m01 = 0,long long m10 = 0,long long m11 = 0):m_00(m00),m_01(m01),m_10(m10),m_11(m11) {}//成員變數long long m_00;long long m_01;long long
Time of Update: 2018-12-03
/*堆排序(大頂堆)*/ //建立一個大頂堆後,在調整成小頂堆,然後輸出#include <iostream>#include<algorithm>using namespace std;//調整堆//調整以當前節點為父節點的所有子節點和孫子節點。。。void HeapAdjust(int *a,int i,int size) { int lchild=2*i; //i的左孩子節點序號 int rchild=2*i+1;
Time of Update: 2018-12-03
為了提高CPU的儲存效率,編譯器往往對class 和 struct 自訂類型進行記憶體對齊。記憶體對齊的規則視編譯器不同而不同。 我們可以使用#pragma pack(n)來設定成 n位元組的對齊 類中的static變數不會給類帶來空間負擔,也就是不被計算到類的大小中。 #include <iostream>using namespace std;#pragma pack(4)class CTest{private:char ch;int n;static char
Time of Update: 2018-12-03
書籍收藏留著以後慢慢讀C類:《C和指標》《C陷阱與缺陷》《C專家編程》windows類:《Windows核心編程》《COM本質論》《深入淺出MFC》《VC++深入詳解》Unix類:《深入理解 Linux 核心》《Unix環境進階編程》《UNIX網路編程》《UNIX 編程藝術》《TCP/IP詳解》C++類《C++ Cookbook》《C++沉思錄》《深度探索C++物件模型》《STL 源碼剖析》《C++編程思想》《Effective C++》《More Effective
Time of Update: 2018-12-03
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <time.h>using namespace std;void Shell_Sort(int a[], int n) { int h,i,j,temp; for (h=n/2; h>0; h=h/2) { for (i=h; i<n; i++)
Time of Update: 2018-12-03
死結:指多個進程因競爭共用資源而造成的一種僵局,若無外力作用,這些進程都將永遠不能再 向前推進。安全狀態與不安全狀態:安全狀態指系統能按某種進程順序來為每個進程分配其所需資源,直 至最大需求,使每個進程都可順利完成。若系統不存在這樣一個序列, 則稱系統處於不安全狀態。 產生死結的原因:(1)競爭系統資源
Time of Update: 2018-12-03
#include <map>#include <iostream>#include <fstream>#include <stdio.h>#include <stdlib.h>#include <string>#include <vector>#include <iomanip>using namespace std;int main(int argc,char **argv){//開啟