c++ 常用的代码例子(字符倒序,整数合并)
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <TlHelp32.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
//#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include<string>
#include<vector>
#include<cstring>
#include <list>
#include <set>
#include <algorithm>
#include <sstream>
//#include <afxdb.h>
using std::cout;
using std::endl;
using namespace std;
void Func2D(int** a,int d1,int d2)//指向指针的指针来指向二维数组
{
for (int i=0;i<d1;i++)
{
for (int j=0;j<d2;j++)
{
a[i][j] = (i+1)*(j+1);
}
}
}
void PrintStr (std::string& StringToPrint) //打印字符串
{
cout << StringToPrint << endl;
}
void PrintIt (int i) //打印数字
{
cout << i << endl;
}
class NullClass//空类
{
};
/*
bool isContains (std::string first, std::string second)
{
if (first.compare(second)==0) return true;
else return false;
}*/
bool isContains (int first, int second)
{
return true;
//if (first != second) return true;
//else return false;
}
bool mycomparison (string first, string second)
{
//if (first.compare(second) >= 0) return true;
//else return false;
cout<<first<<"=="<<second<<endl;
return false;
}
void myreverse(char* ch,int size)//倒序
{
//cout<<ch<<"大小:"<<size<<endl;
list<char> l(ch,ch+size);
int tmp = size-2;
for (list<char>::iterator it=l.begin();it != l.end();it++)
{
cout<<*it<<"指针:"<<*(ch+tmp)<<endl;
if (tmp == -1)//如果是最后一个\0
{
*(ch+(size-1)) = *it;
}
else
{
*(ch+tmp) = *it;
}
tmp--;
}
l.clear();
tmp = 0;
}