Time of Update: 2018-12-04
注意:char tempA[20] = {'/0'}; tempA實際的長度是0。 char* a={'/0'} ; a的長度也是0,但是這樣聲明以後,就不能再*(a+i)這樣逐個賦值了 字串=字元數組+'/0' =========================================#include <stdio.h>#include <stdlib.h>#include
Time of Update: 2018-12-04
#include <iostream>using namespace std;const int N = 1000;void SelSubstr(int flag[],int count){ for(int i = 0;i < count;i++) { flag[i] = flag[i]^1; //當前元素取反後為0則停止。這樣取反正好有2^n-1種情況,而且不重複。 if(!flag[i]) break; }}void print(int flag[],int
Time of Update: 2018-12-04
MFC六大關鍵技術之剖析(第一部分)——MFC程式的初始化過程 http://blog.csdn.net/liyi268/archive/2005/02/22/297875.aspxMFC六大關鍵技術之剖析(第二部分)——運行時類型識別(RTTI) http://blog.csdn.net/liyi268/archive/2005/02/27/304175.aspx MFC六大關鍵技術剖析(第三部分) ——動態建立
Time of Update: 2018-12-04
(一) 問題描述: /** * 請編寫程式求解籃球錯排問題。 * 已知n個籃子一字排開(n為使用者輸入的任意正整數),從左至右分別標著號:1,2,... ...,n;每個球也有編號,分別也是1,2,... ...,n。 * 現要將這n個球全部放入這n個籃子中,滿足:每個籃子放置1個球,球的號不能與其所在的籃子的號相同,且在相鄰籃子內的球的球號不能相鄰。 *
Time of Update: 2018-12-04
#include <iostream>#include <fstream>using namespace std; int a[100]; //存放從檔案中讀入的整數值的數組int n = 0; //記錄數組中 //返回數組中的最大值int Maxa(int a[],int n){ int max = a[0]; for(int i=1;i<n;i++) { if(a[i]>max) max = a[i]; } return
Time of Update: 2018-12-04
#include <iostream>using namespace std; //RecStr_1(char* src)是先將每個單詞進行翻轉,然後進行全域翻轉void RecStr_1(char* src){ char* start=src,*end = src,*ptr = src; while(*ptr++!='/0') //遍曆字串,將每個單詞翻轉 { if(*ptr==' '||*ptr=='/0'||*ptr=='.'||*ptr==',') //找到一個單詞 {
Time of Update: 2018-12-04
“如果一門語言不能影響你對編程的想法,那它就不值得去學” ——Alan
Time of Update: 2018-12-04
問題:從標準輸入讀入任意多個字串,字串用#分割。最後輸入一個固定的標識輸入結束的字串,如“;/*.”,對輸入的所有字串按字典序排序,並輸出到一個檔案中。同時統計出字串個數、最長字串、最短字串。 測試字串如: qwer#uoy iiu89;#yuiji799#yuiojs;pp#dgfdb#abc;/*. ============================================== #include <iostream>#include <fstream>
Time of Update: 2018-12-04
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <iostream.h>char* commonstring(char* str1,char* str2){ char* shortstr,*longstr; char* substr; if(str1==NULL||str2==NULL) return
Time of Update: 2018-12-04
一、遞迴(1)=====#include <iostream> #include <string> using namespace std; string DecToStr(unsigned n) { return n > 0 ? DecToStr(n/10) + static_cast<char>(n%10 + '0') : ""; } int main() { long n=12345608; cout << DecToStr(n)&
Time of Update: 2018-12-04
寫一個3D向量類CVector3D,要求含三種建構函式,並有拷貝,點積,叉積,求模,單位化等操作,並實現”+; -; =; ==; +=; -=; *; [ ]” 等運算子的重載。 註:由於開始定義的時候,沒有將三維資料對應的成員變數使用數組存放,因此重載下標運算子'[ ]'沒有意義。 ================================================ #include <iostream>#include <cmath>using
Time of Update: 2018-12-04
#include <iostream>using namespace std; char* LoopRightMove(char* str,int n){ int strLen = strlen(str); n = n % strLen; //計算字元尾部的字串移動到頭部的個數 char* result = new char[strLen+1]; for(int i=0;i<strLen;i++) { if(i<n) result[i] = str[strLen-
Time of Update: 2018-12-04
(一) O(n)時間的解法 只能解出最後一個出局的人,也就是最後留下的人——預設是從編號為1的人開始數起 n個人在一個圓桌上吃飯,每m個人殺掉一個,直到最後剩下一個人。問最後剩下哪個人?將人分別標記為0,1,2,...,n-1,得到n的一個完全剩餘系。可得如下遞推公式: /- (J(n-1,m)+m+1) mod n, 當n>1J(n,m)=| ,
Time of Update: 2018-12-04
總結: 8皇后的解有92種,但由於對稱性,真正獨立的解是12種 其中一種方案只能衍生出4個答案的情況, 所以不重複的方案是12個,其中一個是對稱圖形,最終結果是11*8+1*4=92。 那個特殊方案就是: . . X . . . . . . . . . X . . . . X . . . . . . . . . . . .
Time of Update: 2018-12-04
#include <iostream>using namespace std;char* toLower(char* sSrcStr){ char* sDest= NULL; if(sSrcStr!=NULL) { int j = 0,sLen; sLen = strlen(sSrcStr); sDest = new char[sLen+1]; if(*sDest==NULL) return NULL; sDest[sLen] =
Time of Update: 2018-12-04
來自《C/C++軟體工程師就業求職手冊》 p150書中的解法是錯的 #include <iostream>using namespace std; void Calculate(const char* str,int& max0,int& max1){ int temp0 = 0; //儲存連續0的長度 int temp1 = 0; while(*str) //遍曆字串 { if(*str=='0') //當前的是0 { max0++; if(*(
Time of Update: 2018-12-04
來自:http://it.btbctv.cn/n/200609/16/n20060916_61682.shtml 一、概述:Symbian OS是一個多任務的作業系統,那麼為了實現多任務,同時使系統能夠快速響應,高效的進行事件處理,並減輕應用程式員的工作負擔(申請大多數耗時的操作(例如檔案系統)由服務提供器來完成,服務提供器完成程式員提交的請求後,將會返回給程式員一個成功或失敗的訊號。), Symbian
Time of Update: 2018-12-04
#include <iostream>using namespace std; //在一個含有不重複的字串中尋找一個字元的位置,不存在返回NULL char* findc(char* p, char c){ int flag = 0; //預設不存在 while(*p++) { if(*p==c) { flag = 1; break; } } if(flag) return p; else return NULL;}char* DeleteStr(char*
Time of Update: 2018-12-04
Symbian學習筆記(2)——基本概念 第一次開啟SymbianC++的程式原始碼,第一感覺就是“這是C/C++嗎?咋這麼眼生啊”。看代碼看書,才算是稍稍明白了一點,其實無非就是typedef罷了,symbian可比brew定義了更多的東西。這是以後幹活的基礎,所以做個筆記,省得忘了。一、基礎資料型別 (Elementary Data Type)這個比較簡單,都在e32def.h中寫著呢。也就是以下這幾個類型要注意一下,以後照著寫罷了,含義也很明了,不用多說。typedef void
Time of Update: 2018-12-04
1. char* strcat(char* dest,char* src) #include <stdio.h>#include <stdlib.h>char* mystrcat(char* des,char* src){ char* ret = des; while(*des++); //是指標指向末尾的下二位 des--; //指標指向'/0' while(*des++=*src++); return ret;}int main(){ char*