【面試題】一個數組a[n-1]缺失了1到n之間的哪個數?

#include <stdio.h>#define N 10int main(){ int a[N-1]={3,9,4,5,2,6,1,8,10}, missing=0; for(int i=1; i<=N-1; i++){missing+=i-a[i-1]; }missing+=N; printf("Missing Number: %d\n", missing); return 0;}對於丟失一個數的情況:

【面試題】兩個n*n的矩陣相乘–採用一位元組表示

#include <iostream>#include <math.h>using namespace std;void MatrixMultiplication(int * pArry1, int *pArry2, int * pDestArry, int len){int row ;int col;row= col = (int)sqrt((double)len);if (row * col != len) //矩陣不為方陣則提示矩陣無效{cout <<

【筆試題】關於地址轉換的破事

#include <iostream>#include <stdio.h>#include <string.h>#include <conio.h>using namespace std;int main(){cout << "unsigned char" <<sizeof(unsigned char)<<endl;//1cout << "signed char

STL 優先隊列 priority_queue 的使用

#include<stdio.h>#include<functional>#include<queue>#include<vector>using namespace std; struct cmp{ bool operator ()(double &a,double &b){ return a<b;} }; double a[]={12.3,34.5,9.5,2.4,6.8,7.0,33.6}; int

【面試題】eax寄存器—16位的。

#include <iostream>using namespace std;void main(){unsigned char a = 0xA5;unsigned char b = ~a >> 4+1;printf("b = %d \n",b);}//250//這裡的局部變數a放在16位的寄存器中!!!!這裡需要注意的是a雖然是無符號char型,只佔一個位元組,但是它存放在一個eax寄存器,是16位的。。。於是在機器中0xA5的寄存中運算式為0000 0000 1010

char *s 與 char s[] 的恩恩怨怨

#include <iostream>using namespace std;void main(){char *str = "Hello";//"hello“是儲存在字串常量儲存地區,s為其收地址,該地區是不能修改的。*str++ = 'Q';//運行崩潰cout << str <<endl;char arr[] =

棧中變數的記憶體布局

#include <iostream>using namespace std;void main(){int a = 1;int b = 2;int c = 3;cout << sizeof(a) <<endl;int *pa= &a;printf("&a=%x\n",pa);int *pb = &b;printf("&b=%x\n",pb);int *pc = &c;printf("&c=%x\n",pc);}

【面試題】sizeof 擷取自訂類,結構體,vector,map,string的占記憶體大小

#include <iostream>#include <vector>#include <map>#include <string>using namespace std;struct a{short aa;//2short b;//2short c;//2};//6struct b{char x;//1char y;//1char z;//1short q;//2};//6class c{private:int a;//4char

常成員函數和mutable的恩恩怨怨

在C++的成員函數中,有一種成員函數叫做常成員函數,形如:int get() const;據百科中記載:常成員函數 含義 是通過該函數只能讀取同一類中的資料成員的值,而不能修改它。那麼要是修改了呢?那當然得到的是一個編譯錯誤。。。。那我要是非要修改呢?這時,mutable就出現了。Mutable 關鍵詞的作用是:可以在常函數中被修改其值。mutable使用的兩種情況舉例: class Employee {public: Employee(const std::string &

what is placement new??

placement new是重載operator new的一個標準、全域的版本,它不能被自訂的版本代替(不像普通的operator new和operator delete能夠被替換成使用者自訂的版本)。它的原型如下:void *operator new( size_t, void *p ) throw()  { return p; }首先我們區分下幾個容易混淆的關鍵詞:new、operator new、placement new new和delete操作符我們應該都用過,它們是對堆中的記憶體進行

【面試題】關於GetMemory的故事

#include <iostream>using namespace std;void GetMemory(char *p, int num){p = (char *)malloc(sizeof(char) * num);}void main(){char *str = NULL;GetMemory(str,100);strcpy(str,"Hello");}//編譯通過,但運行錯誤。//0x61aef689 (msvcr90d.dll) 處未處理的異常: 0xC0000005:

char s[] 和 const char s[]和char *s和const char *s 是否可以修改元素。

 #include <iostream>using namespace std;void main(){ char s1[]="abc"; char s2[]="abc"; //cout << (s1==s2) <<endl;//0 //s1[1]='x';//編譯正確,輸出axc //cout << s1 <<endl; const char s3[]="abc"; const char s4[]="abc"; //cout <

【面試題】括弧匹配

使用STL中的stack#include <iostream>#include <stack>#include <assert.h>using namespace std;bool isValidSeq(char *s){assert(s != NULL);stack<char> st;char *p = s;while(*p != '\0'){if(!st.empty()){if(st.top() == '(' && *p ==

Ping命令的原理

PING的實現過程很簡單,命令將引發IP層發送一個簡單的IP包,而目的方收到這個包之後,將源和目的地址做一下交換,重新發出這個包即可,當然還要加一些逾時的機制。   假定主機A的IP地址是192.168.1.1,主機B的IP地址是192.168.1.2,都在同一子網內,則當你在主機A上運行“Ping

【面試題】itoa實現

#include <iostream>#include <stack>using namespace std;char *itoa_bxy(int num, char *a,int radix){char *tmp = a;int flag = num;//如果是負數,採用相反數來計算if(flag < 0){num = -num;}//從低位開始遍曆數字,入棧。stack<char> s;while(num != 0){char x = num %

Face Track 中 人臉特徵點對應關係

1-32----->臉頰=========0-16一共17個點33-40---->右眼眉=======17-21一共5個點41-48---->左眼眉=======22-26一共5個點49-54---->鼻樑=========27-30一共4個點55-62---->鼻子=========31-35一共5個點63-74---->右眼=========36-41一共6個點75-86---->左眼=========42-47一共6個點87-110--->外

把一個檔案夾下的多幀映像資料轉成一個檔案中,方便動態特徵圖

#include <iostream>#include <fstream>#include <vector>#include <string>#include <sstream>#define NUM_FILE 24using namespace std;void main(){vector<int> x;vector<int> y;for(int i=1; i <= NUM_FILE;

【筆試題】數組 字元指標 地址

    #include <iostream>using namespace std;void main(){char s1[]="abc";char s2[]="abc";cout <<boolalpha<< (s1==s2) <<endl;const char s3[]="abc";const char s4[]="abc";cout <<(s3==s4) <<endl;char *s5="abc";char *s6="

靜態路由和動態路由的區別

靜態路由  是在路由器中設定的固定的路由表。除非網路系統管理員幹預,否則靜態路由不會發生變化由於靜態路由不能對網路的改變作出反映,一般用於網路規模不大、拓撲結構固定的網路中。靜態路由的優點是簡單、高效、可靠。在所有的路由中,靜態路由優先順序最高。當動態路由與靜態路由發生衝突時,以靜態路由為準動態路由  是網路中的路由器之間相互連信,傳遞路由資訊,利用收到的路由資訊更新路由器表的過程。它能即時地適應網路結構的變化。如果路由更新資訊表明發生了網路變化,路由選擇軟體就會重新計算路由,並發出新的路由更新

Gabor特徵提取 保留版

Gabor變換由兩個檔案組成一個是gabor變換: spatialgabor.m % SPATIALGABOR - applies single oriented gabor filter to an image%% Usage:% [Eim, Oim, Aim] = spatialgabor(im, wavelength, angle, kx, ky, showfilter)%% Arguments:% im - Image to be processed.

總頁數: 61357 1 .... 21101 21102 21103 21104 21105 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.