freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c語言軟件工程師筆試題精華-資料下載頁

2024-10-14 03:55本頁面
  

【正文】 g)!=NULL)//如果??,那么返回shortstring return shortstring。for(i=strlen(shortstring)1。i0。i–)//否則,開始循環(huán)計算 { for(j=0。jstrlen(str2))//將短的字符串放前面 man=manstring(str2, str1)。elseman=manstring(str1, str2)。printf(“the longest man string is: %sn”, man)。}2寫一個函數(shù)比較兩個字符串str1和str2的大小,若相等返回0,若str1大于str2返回1,若str1小于str2返回-1int strcmp(const char * src,const char * dst){int ret = 0。while(!(ret = *(unsigned char *)src – *(unsigned char *)dst)amp。amp。 *dst){++src。++dst。}if(ret 0)ret =1。else if(ret 0)ret = 1。return(ret)。}2求1000!的未尾有幾個0(用素數(shù)相乘的方法來做,如72=2*2*2*3*3)。求出11000里,能被5整除的數(shù)的個數(shù)n1,能被25整除的數(shù)的個數(shù)n2,能被125整除的數(shù)的個數(shù)n3, !末尾的零的個數(shù)=n1+n2+n3+n4。includedefine NUM 1000 int find5(int num){ int ret=0。while(num%5==0){ num/=5。ret++。}return ret。}int main(){ int result=0。int i。for(i=5。iresult+=find5(i)。}printf(“ the total zero number is %dn”,result)。return 0。}有雙向循環(huán)鏈表結(jié)點定義為: struct node { int data。struct node *front,*next。}。有兩個雙向循環(huán)鏈表A,B,知道其頭指針為:pHeadA,pHeadB,請寫一函數(shù)將兩鏈表中data值相同的結(jié)點刪除BOOL DeteleNode(Node *pHeader, DataType Value){ if(pHeader == NULL)return。BOOL bRet = FALSE。Node *pNode = pHead。while(pNode!= NULL){ if(pNodedata == Value){ if(pNodefront == NULL){ pHeader = pNodenext。pHeaderfront = NULL。} else { if(pNodenext!= NULL){ pNodenextfront = pNodefront。} pNodefrontnext = pNodenext。} Node *pNextNode = pNodenext。delete pNode。pNode = pNextNode。bRet = TRUE。//不要break或return, 刪除所有 } else { pNode = pNodenext。} } return bRet。} void DE(Node *pHeadA, Node *pHeadB){ if(pHeadA == NULL || pHeadB == NULL){ return。}Node *pNode = pHeadA。while(pNode!= NULL){if(DeteleNode(pHeadB, pNodedata)){if(pNodefront == NULL){pHeadA = pNodenext。pHeadAfront = NULL。} else {pNodefrontnext = pNodenext。if(pNodenext!= NULL){pNodenextfront = pNodefront。} }Node *pNextNode = pNodenext。delete pNode。pNode = pNextNode。} else {pNode = pNodenext。} } }3編程實現(xiàn):找出兩個字符串中最大公共子字符串,如”abccade”,”dgcadde”的最大子串為”cad” int GetCommon(char *s1, char *s2, char **r1, char **r2){int len1 = strlen(s1)。int len2 = strlen(s2)。int maxlen = 0。for(int i = 0。i len1。i++){for(int j = 0。j len2。j++){if(s1[i] == s2[j]){int as = i, bs = j, count = 1。while(as + 1 len1 amp。amp。 bs + 1 len2 amp。amp。 s1[++as] == s2[++bs])count++。if(count maxlen){maxlen = count。*r1 = s1 + i。*r2 = s2 + j。} } } }3編程實現(xiàn):把十進(jìn)制數(shù)(long型)分別以二進(jìn)制和十六進(jìn)制形式輸出,不能使用printf系列庫函數(shù) char* test3(long num){ char* buffer =(char*)malloc(11)。buffer[0] = ’0′。buffer[1] = ‘x’。buffer[10] = ‘′。char* temp = buffer + 2。for(int i=0。i 8。i++){ temp[i] =(char)(num28)。temp[i] = temp[i] = 0 ? temp[i] : temp[i] + 16。temp[i] = temp[i] 10 ? temp[i] + 48 : temp[i] + 55。} return buffer。}3輸入N, 打印 N*N 矩陣 比如 N = 3,打印: 1 2 3 8 9 4 7 6 5 N = 4,打?。?1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7 解答: define N 15 int s[N][N]。void main(){ int k = 0, i = 0, j = 0。int a = 1。for(。k k1)s[i][j] = a++。i–。j++。while(i k)s[i][j] = a++。i++。j++。} for(i = 0。i N。i++){ for(j = 0。j N。j++)cout int matrix[MAX_N][MAX_N]。/**(x,y):第一個元素的坐標(biāo) * start:第一個元素的值 * n:矩陣的大小 */void SetMatrix(int x, int y, int start, int n){ int i, j。if(n if(n == 1){ //矩陣大小為1時 matrix[x][y] = start。return。}for(i = x。i x + n1。i++)//矩陣上部 matrix[y][i] = start++。for(j = y。j y + n1。j++)//右部 matrix[j][x+n1] = start++。for(i = x+n1。i x。i–)//底部 matrix[y+n1][i] = start++。for(j = y+n1。j y。j–)//左部 matrix[j][x] = start++。SetMatrix(x+1, y+1, start, n2)。//遞歸 }void main(){ int i, j。int n。scanf(“%d”, amp。n)。SetMatrix(0, 0, 1, n)。//打印螺旋矩陣for(i = 0。i n。i++){ for(j = 0。j n。j++)printf(“%4d”, matrix[i][j])。printf(“n”)。} }3斐波拉契數(shù)列遞歸實現(xiàn)的方法如下: int Funct(int n){if(n==0)return 1。if(n==1)return 1。retrurn Funct(n1)+ Funct(n2)。}請問,如何不使用遞歸,來實現(xiàn)上述函數(shù)? 請教各位高手!解答:int Funct(int n)// n 為非負(fù)整數(shù) { int a=0。int b=1。int c。if(n==0)c=1。else if(n==1)c=1。else for(int i=2。i現(xiàn)在大多數(shù)系統(tǒng)都是將低字位放在前面,而結(jié)構(gòu)體中位域的申明一般是先聲明高位。100 的二進(jìn)制是 001 100 100 低位在前 高位在后 001s3 100s2 100s1 所以結(jié)果應(yīng)該是 1 如果先申明的在低位則: 001s1 100s2 100s3 結(jié)果是 4原題跟littleendian,bigendian沒有關(guān)系原題跟位域的存儲空間分配有關(guān),到底是從低字節(jié)分配還是從高字節(jié)分配,從Dev C++,都是從低字節(jié)開始分配,并且連續(xù)分配,中間不空,不像譚的書那樣會留空位原題跟編譯器有關(guān),編譯器在未用堆棧空間的默認(rèn)值分配上有所不同,Dev C++未用空間分配為 01110111b,,所以在Dev C++下的結(jié)果為5。注:PC一般采用littleendian,即高高低低,但在網(wǎng)絡(luò)傳輸上,一般采用bigendian,即高低低高,華為是做網(wǎng)絡(luò)的,所以可能考慮bigendian模式,這樣輸出結(jié)果可能為43判斷一個字符串是不是回文 int IsReverseStr(char *aStr){ int i,j。int found=1。if(aStr==NULL)return1。j=strlen(aStr)。for(i=0。i if(*(aStr+i)!=*(aStr+ji1)){found=0。break。}return found。}3Josephu 問題為:設(shè)編號為1,2,? n的n個人圍坐一圈,約定編號為k(1int Josephu(int n, int m){int flag, i, j = 0。int *arr =(int *)malloc(n * sizeof(int))。for(i = 0。i n。++i)arr[i] = 1。for(i = 1。i n。++i){flag = 0。while(flag m){if(j == n)j = 0。if(arr[j])++flag。++j。}arr[j1] = 0。printf(“第%4d個出局的人是:%4d號n”, i, j)。}free(arr)。return j。}int main(){int n, m。scanf(“%d%d”, amp。n, amp。m)。printf(“最后勝利的是%d號!n”, Josephu(n, m))。system(“pause”)。return 0。}鏈表實現(xiàn): include includetypedef struct Node { int index。struct Node *next。}JosephuNode。int Josephu(int n, int m){ int i, j。JosephuNode *head, *tail。head = tail =(JosephuNode *)malloc(sizeof(JosephuNode))。for(i = 1。i n。++i){ tailindex = i。tailnext =(JosephuNode *)malloc(sizeof(JosephuNode))。tail = tailnext。} tailindex = i。tailnext = head。for(i = 1。tail!= head。++i){ for(j = 1。j m。++j){ tail = head。head = headnext。} tailnext = headnext。printf(“第%4d個出局的人是:%4d號n”, i, headindex)。free(head)。head = tailnext。} i = headindex。free(head)。return i。} int main(){ int n, m。scanf(“%d%d”, amp。n, amp。m)。printf(“最后勝利的是%d號!n”, Josephu(n, m))。system(“pause”)。return 0。} 第四部分:附加部分位域 :有些信息在存儲時,并不需要占用一個完整的字節(jié),而只需占幾個或一個二進(jìn)制位。例如在存放一個開關(guān)量時,只有0和1 兩種狀態(tài),用一位二進(jìn)位即可。為了節(jié)省存儲空間,并使處理簡便,C語言又提供了一種數(shù)據(jù)結(jié)構(gòu),稱為“位域”或“位段”。所謂“位域”是把一個字節(jié)中的二進(jìn)位劃分為幾個不同的區(qū)域,并說明每個區(qū)域的位數(shù)。每個域有一個域名,允許在程序中按域名進(jìn)行操作。這樣就可以把幾個不同的對象用一個字節(jié)的二進(jìn)制位域來表示。一、位域的定義和位域變量的說明位域定義與結(jié)構(gòu)定義相仿,其形式為: struct 位域結(jié)構(gòu)名 { 位域列表 }。其中位域列表的形式為: 類型說明符 位域名:位域長度 例如: struct bs {int a:8。int b:2。int c:6。}。位域變量的說明與結(jié)構(gòu)變量說明的方式相同。可采用先定義后說明,同時定義說明或者直接說明這三種方式。例如: struct bs {int a:8。int b:2
點擊復(fù)制文檔內(nèi)容
研究報告相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1