»ùÓÚÑî»ÔÈý½ÇµÄ×éºÏÊý¼ÆËãËã·¨(C++ʵÏÖ)
¹ØÓÚ×éºÏÊý¼ÆËãµÄËã·¨ÎÒдÁ˺ü¸¸ö£¬·¢ÏÖÑî»ÔÈý½Ç²é±í·¨Ð§ÂʱȽϸߣ¡
²¢ÇÒÕâ¸öËã·¨ÀûÓÃC(n,k) = C(n,n-k)À´¼ò»¯Ñî»ÔÈý½ÇµÄÊý×飬Ëã·¨µÄʱ¼ä¸´ÔӶȱȽϵ͡£
Ô´´£¬Ë®Æ½ÓÐÏÞ£¬ÈçÓв»×㣬»¶ÓÖ¸³ö¡£
Mail£ºrainday163@163.com
ÏÂÃæÊÇÎÒдµÄ´úÂë²¢¸½´ø²âÊÔº¯Êý£ºDev-C++ 4.9.9.2ϲâÊÔͨ¹ý¡£
/*---------------------------------------------------------------------
//file name:combination.cpp
//Coder: rainday163
//E-mail: rainday1631@163.com
//Create date: 2009.9.4
//Last modify date: 2009.9.28
//Test platform: WinXP sp2 & Dev-C++ 4.9.9.2
---------------------------------------------------------------------*/
#include <typeinfo>
#include <vector>
#include <stdexcept>
#include <iostream>
template <typename T1,typename T2>
T1 combination(T2 const &n,T2 const &k)
{
//ÀàÐͼì²é
if( !( (typeid(T1) == typeid(unsigned long long))
||(typeid(T1) == typeid(long long))
||(typeid(T1) == typeid(unsigned long))
||(typeid(T1) == typeid(long))
||(typeid(T1) == typeid(unsigned int))
||(typeid(T1) == typeid(int))
||(typeid(T1) == typeid(unsigned short))
||(typeid(T1) == typeid(short)) ) )
{
throw std::out_of_range("Type of return value Error!");
}
if( !( (typeid(T2) == typeid(long))
|| (typeid(T2) == typeid(unsigned int))
|| (typeid(T2) == typeid(int))
|| (typeid(T2) == typeid(unsigned short))
|| (typeid(T2) == typeid(short))
) )
{
throw std::out_of_range("Type of parameter Error!");
}
if((n|k)<0)//È·±£n,kΪÕýÖµ
{
throw std::out_of_range("Error£ºnegative parameter!");
}
if(n<k)
{
throw std::out_of_range("Error£ºK > N ,Please check your input!");
&nb
Ïà¹ØÎĵµ£º
/*
* File: main.cpp
* Author: Vicky
*
* Created on 2010Äê5ÔÂ8ÈÕ, ÏÂÎç2:47
*/
#include <iostream>
using namespace std;
void swap(int x, int y) {
cout << "x and y swap before : " << x << "\t" << y << endl;
int i = x;
x = y;
y = i; ......
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ¼ÆµÄÓÐÓõÄCÓïÑÔÔ´´úÂëƬ¶Î
2¡¢http://www.hotscripts.com/category/c-cpp/scripts-programs/ Hotscripts --ÌṩÊýÒ԰ټƵÄCºÍC++½Å±¾ºÍ³ÌÐò¡£ËùÓгÌÐò¶¼·ÖΪ²»Í¬µÄÀà±ð¡£
3¡¢http://www.planetsourcecode.com/vb/default.asp?lngWId=3 --³¬¹ýÍòÐÐCºÍC++Ãâ·ÑµÄÔ´´úÂë
4¡ ......
LinuxÏÂC++¿ª·¢¹¤¾ß½éÉÜ
¡¡¡¡¸ÅÊö
¡¡¡¡¾ÍC£«£«¿ª·¢¹¤¾ß¶øÑÔ£¬ÓëWindowsÏÂ΢Èí£¨VC£¬ VS2005µÈ£©Ò»Í³ÌìÏÂÏà±È£¬Linux/UnixÏÂC£«£«¿ª·¢£¬¿ÉνÎ廨°ËÃÅ£¬¸÷ʽ¸÷Ñù¡£Emacs, vi, eclipse, anjuta£¬kdevelopµÈ²ã³ö²»Çî¡£
¡¡¡¡WindowsÏ£¬¿ª·¢¹¤¾ß¶àÒÔ¼¯³É¿ª·¢»·¾³IDEµÄÐÎʽչÏÖ¸ø×îÖÕÓû§¡£ÀýÈ磬VS2005¼¯³ ......
1:ÔÚStaAfx.h ÖÐÌí¼ÓÈçÏ´úÂë #import "C:\\Program Files\\Common Files \\System\\ado\\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
2:ÔÚBOOL CXXXApp::InitInstance()Öгõʼ»¯COM»·¾³
::CoInitialize(NULL);
ÊÍ·ÅCOM»·¾³
::CoUninitialize();
......
C/C++ Reference
http://www.cppreference.com/
C++ Library Reference
http://www.cplusplus.com/ref/
Standard C++ Library Class Reference at Rogue Wave
http://www.roguewave.com/support/docs/hppdocs/stdref/
Dink ......