> 2009/05/27 (水) 22:14:59 ◆ ▼ ◇ [qwerty]> > やっぱり住人はすごいな(;´Д`)Perlで書いてください
> http://krokus.sakura.ne.jp/topun/source/topun0259.jpg
> いろいろ動くように直したよVC++用無料のでも動くだろうが(;´Д`)perlは簡便してください
> #include "stdafx.h"
> #include <stdlib.h>
> #include <string>
> int table[]={1,5,3,2,8,4,9};
> int ntable = sizeof(table)/sizeof(int);
>
> int func( std::string &str, int total, int *tbl, int ntbl)
> {
> for(int i=0;i<ntbl-1; ++i){
> std::string s = str+",";
> char buf[0x10];
> _itoa_s(tbl[i],buf,0x10,10);
> s += buf;
> if( total+tbl[i]==9){
> printf("みつけたよ(%s)\n", s.c_str());
> } else {
> func( s, total+tbl[i], &tbl[i+1], (ntbl-(i+1) ) );
> }
> }
> return total;
> }
> int _tmain(int argc, _TCHAR* argv[])
> {
> std::string str;
> func(str, 0, table, ntable);
>
> return 0;
> }
数字300個で試してみたのだが固まった(;´Д`)文句言ってごめんよ
参考:2009/05/27(水)22時04分18秒