1. "读空白字符,返回是否为空"
    2. cin.get(char);
    3. "读取未知个数int"
    4. while (cin >> n){
    5. sum += n;
    6. }
    7. "读入string"
    8. cin >> s;
    9. getline(cin, s, ',');"以,为结束符"
    10. "从缓冲区读入n个int"
    11. copy_n(istream_iterator<int>(cin),n,nums);
    12. "将nums中的数据以->为间隔符输出"
    13. copy(begin(nums),end(nums),ostream_iterator<int>(cout,"->"));
    14. "转16进制"
    15. # include<string>
    16. # include<sstream>
    17. stringstream ioss;
    18. string s_temp;
    19. ioss << hex << num;
    20. ioss >> s_temp;
    21. "转二进制"
    22. void tobin(int a,char* str){
    23. char *p=(char*)&a,c=0,f=0,pos=-1;//p指向a的首地址
    24. for(int o=0;o<4;++o){
    25. for(int i=0;i<8;++i){
    26. c=p[3-o]&(1<<(7-i));
    27. if(!f&&!(f=c))continue;
    28. str[++pos]=c?'1':'0';
    29. }
    30. }
    31. }
    32. "string补全位数"
    33. if (length>s_temp.length()){
    34. string s_0(8 - s_temp.size(), '0');
    35. s_temp = s_0 + s_temp;
    36. }
    37. "自定义排序"
    38. class Weibo{};
    39. bool cmp(Weibo *a, Weibo *b) {
    40. return a->getTime() > b->getTime();
    41. }
    42. vector<Weibo *> output;
    43. sort(output.begin(),output.end(), cmp);