Last active
December 12, 2017 14:39
-
-
Save murnana/f9147208b95492b7c00904e8f92a69d0 to your computer and use it in GitHub Desktop.
C - Shopping Street写し
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int ans = -1000000000; // グローバル変数として、答えを入れる変数を用意する | |
int a[10]; // こちらは、実際の営業フラグを入れる | |
// 最終的な答えを出す関数 | |
void func(void) { | |
if( a ○○○○○○) return; | |
int score = ;// aだった時のスコア | |
ans = max(ans,score); | |
} | |
// 総当たりのための関数 | |
void difs(int pos) { | |
if( pos => 10 ) { | |
// 10個以上は計算しないので、ここでおわり! | |
func(); | |
return; | |
} else { | |
// ここでどんどんansを更新する | |
a[pos] = 0; difs(pos+1); | |
a[pos] = 1; difs(pos+1); | |
} | |
} | |
int main(void) | |
{ | |
// | |
// 入力を済ませる | |
// | |
defs(0); // 0 からスタート | |
cout << ans << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment