Chinaunix首页 | 论坛 | 博客
  • 博客访问: 838170
  • 博文数量: 158
  • 博客积分: 4380
  • 博客等级: 上校
  • 技术积分: 2367
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-21 10:45
文章分类

全部博文(158)

文章存档

2012年(158)

我的朋友

分类: C/C++

2012-11-23 15:27:25

专门保存代码片断

阅读(8957) | 评论(66) | 转发(0) |
给主人留下些什么吧!~~

网友评论2012-11-23 15:37:19

周星星
执行控制台命令,并获得其输出(1),参见 http://blog.vckbase.com/bruceteen/articles/25581.html#34202

#include <stdio.h>
#include <stdlib.h>

int execmd( const char* cmd )
{
    FILE* pPipe = _popen( cmd, "rt" );
    if( pPipe )
    {
        // 适用于没有输入交互,没有长时间等待的情况

网友评论2012-11-23 15:37:05

周星星
#include <iostream>
#include <algorithm>
#include <iterator>
#include <functional>
using namespace std;

struct greaterequal2_and_lessequal3 : binary_function<int, int, bool>
{
    bool operator()( const int& lhs, const int& rhs ) const
    {
        return ( lhs<2 && rhs>=2 ) || ( lhs<=3 && rhs>3 );<

网友评论2012-11-23 15:36:55

周星星
#include <iostream>
#include <algorithm>
#include <iterator>
using namespace std;

int main()
{
    int a[] = { 1,1,2,2,3,3 };

    // 返回第一个大于或等于指定值的迭代器
    int* p1 = lower_bound( a+0, a+_countof(a), 2 );
    // 返回第一个大于指定值的迭代器
    int* p2 = upper_bound( a+0, a+_countof(a), 2 );
    copy( p1, p2, ostream_iterator<in

网友评论2012-11-23 15:36:45

周星星
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;

int main()
{
    int a[] = { 1, 1, 2, 2, 2 };
    int b[] = { 2, 2, 3, 3 };
    // assert( a, b 是有序的 )

    // 并集 1 1 2 2 2 3 3
    {
        int c[10];
      

网友评论2012-11-23 15:36:34

周星星
Bytes Encoding Form
00 00 FE FF UTF-32, big-endian
FF FE 00 00 UTF-32, little-endian
FE FF UTF-16, big-endian
FF FE UTF-16, little-endian
EF BB BF UTF-8