1.數字轉string
intx;string
id;stringstream ss;
ss
> id;
2.字串轉數字
intnum;
string
s;stringstream ss(s);
ss>>num;
charstr;
sscanf( str, "%d
", &num ); //
將字串轉換成整數
sscanf( str, "
%f", &floatnum ); //
將字串轉換成浮點數
charstr;
floatnum = atof(str); //
字串轉浮點數
num = atoi(str); //
字串轉整數
若字串為string型別,則要用c_str()方法獲取其字串指標string
str;
floatnum = atof(str.c_str()); //
string轉浮點數
num = atoi(str.c_str()); //
string轉整數
3.結構體內嵌比較函式的規則
如下:
structnode
};
此時左邊那個r表示自己這個r,如果排序的話,會按r值從小到大排序,因為sort預設就是從小到大的。
而優先佇列就不同了,優先佇列中預設是大值優先,所以大小關係相反,比如下面這個:
structsell
};priority_queueque;
那麼這個優先佇列是按price小的優先出隊。
總之記住:結構體中直接寫比較函式一定是左邊那個裸的r表示當前this值,如果r
4.排序vector結構體最好內嵌比較函式
比如內嵌:
booloperator
<(const node &b)const
時 sort(v.begin(),v.end()) 比 sort(v.begin(),v.end(),cmp) 快。 而且是超時的點。 注意!
一些語言方面的技巧
1.數字轉string int x string id stringstream ss ss id 2.字串轉數字 int num string s stringstream ss s ss num char str sscanf str,d num 將字串轉換成整數 sscanf str,f fl...
AIX方面的一些資源
常用aix論壇位址介紹 aix論壇 http loveunix.style images 1 logo4.gif img url 愛u家園 是大家的快樂空間 aix使用者論壇 chinaunix的aix論壇 aix中國論壇 思達奇公司的aix 技術區 itpub的unix論壇 銀信公司 aix練習 ...
sde方面的一些疑問(筆記)
sde 1 arcsde 服務自 arcgis 10.3 起不再可用。但是,arcgis 10.3.1 和更高版本的客戶端仍可以使用 arcsde 服務連線到 10.1 或 10.2.x 版本的地理資料庫。2 arcgis 中的地理資料庫應用程式邏輯還用於讀取和處理所有地理資料來源 如計算機輔助繪圖...