»ùÓÚÑî»ÔÈý½ÇµÄ×éºÏÊý¼ÆËãËã·¨(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
Ïà¹ØÎĵµ£º
CAPTION: ¹ØÓÚC/C++ÖÐÄÚ´æ¿Õ¼äµÄ»®·Ö
AUTHOR: aIsland Õª×ÔÖйúITʵÑéÊÒ
DATE: 2010-05-30
E-MAIL: aIsland@live.cn
QQ: 418662213
P.S.
1.Bolanlan|ËæÐÄhigh|aIsland Èý¸öÍøÃû¾ùΪ±¾ÈË
2.ÉùÃ÷aIsland ËùÊÕ¼µÄËùÓÐÎÄÕÂÆäÖø×÷Ȩ¶¼ÊôÓÚÔ´´×÷Õß
  ......
/*
* 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¡ ......
C/C++
Í·ÎļþÒ»ÀÀ
//////////////////////////////////////////////////////////////////////////
C
Í·Îļþ
(C89,C95)
(C++98,C++03Ò²°üº¬)
include <assert.h>¡¡¡¡¡¡¡¡//Õï¶Ï¿â
include <ctype.h>¡¡¡¡¡¡¡¡ //×Ö·û´¦Àíº¯Êý¿â
include <errno.h>¡¡¡¡¡¡¡¡ //´íÎó¶¨Òå
include <float.h& ......