C/C++/VC 实现字符串逆转的多种方法
/加了下面两个头文件,是为了在Win32工程中使用MFC的特性!
#include <afx.h>
#include <afxwin.h>
#include "stdio.h"
#include "conio.h"
////加了下面两句,是为了能够用string(basic_string类型)
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
// string _strtemp = "1111";
// TRACE("\n string = %s \n",_strtemp.c_str() );
// printf("\n string = %s \n",_strtemp.c_str() );
// printf("\n Hello World! \n");
// getch();
CString sTemp;
sTemp.Format("jkgja");
AfxMessageBox(sTemp);
return 0;
}
/************************************************************************/
/* 实现字符串逆转 */
/************************************************************************/
/////方案一 用纯C函数实现
/*#include <iostream>
#include <string>
using namespace std;
int main()
{
string str = "abcdefghijklmn";
cout<<str.c_str()<<endl;
cout<<strrev(strdup(str.c_str()))<<endl;
system("pause");
return 0;
}*/
///// 方案二 用STL函数实现
// reverse_copy.cpp
// compile with: /EHsc
// Illustrates how to use the reverse_copy function.
//
// Functions:
// reverse_copy - Reverse a sequence, copy the results to another
// same-sized sequence.
//
//////////////////////////////////////////////////////////////////////
/*
// disable warning C4786: symbol greater than 255 character,
// okay to ignore
#pragma warning(disable
相关文档:
由于Boost Python跟不上Python版本更新,如下方法调用可能产生TypeError: 'NoneType' object does not support item assignment异常。
Boost Python文档中例子可能产生异常。
Py_Initialize();
object main_module = import("__main__");
object main_dict = main_module.attr("__dict__");
try{
object ......
Java语言本身具有跨平台性,如果通过Java调用DLL的技术方便易用,使用Java开发前台界面可以更快速,也能带来跨平台性。
Java调用C/C++写好的DLL库时,由于基本数据类型不同、使用字节序列可能有差异,所以在参数传递过程中容易出现问题,DLL中可能需要做相应的转换。
使用Java调用DLL动态链接库的方案通常有三种:JNI, Ja ......
排序算法是一种基本并且常用的算法。由于实际工作中处理的数量巨大,所以排序算法对算法本身的速度要求很高。
而一般我们所谓的算法的性能主要是指算法的复杂度,一般用O方法来表示。在后面我将给出详细的说明。
对于排序的算法我想先做一点简单的介绍,也是给这篇文章理一个提纲 ......
函数 - 声明、定义、调用
1. 如果函数没有声明, 应该在调用前定义:
#include <stdio.h>
/* 定义求大值函数 */
int MAX(int x, int y) {
if (x > y)
return x;
else
return y;
}
/* 定义求小值函数 */
int MIN(int x, int y) {
return x &l ......