C/C++の宿題を片付けます 103代目at TECH
C/C++の宿題を片付けます 103代目 - 暇つぶし2ch607:デフォルトの名無しさん
08/01/25 23:44:26
>>599
#include<stdio.h>
int calc(char *str){
int ret=0, value, idx;
while(sscanf(str, "%d%n", &value, &idx)>0){
ret+=value;
str+=idx;
}
return ret;
}
char *top(char *str){
while(*--str);
return str+1;
}
void check(char *work, int depth){
if(depth<=0){
*work='\0';
if(calc(top(work))==0) puts(top(work));
return;
}
*work++='0'+depth;
if(depth>1){
*work='+';check(work+1, depth-1);
*work='-';check(work+1, depth-1);
}
check(work, depth-1);
}
int main(void){
char str[20]="";
check(str+1, 9);
return 0;
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch