Created
September 14, 2015 13:45
-
-
Save chenyanzhe/881819b76017fd655f51 to your computer and use it in GitHub Desktop.
[腾讯笔试] 2016腾讯校招技术类笔试(大题部分) 第二题
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 main() { | |
int a, b, c, d, e, f, g, h; | |
for (a = 0; a <= 4; a++) { | |
b = 13 - a; | |
for (e = 0; e <= 5; e++) { | |
h = 5 - e; | |
for (d = 1; d <= 9; d++) { | |
c = 4 + d * e; | |
for (g = 1; g <= 9; g++) { | |
if (b - d * g == 4) { | |
f = 4 + h - g; | |
if (1 <= f && f <= 100 && | |
c % f == 0 && | |
a + c / f == 4) { | |
cout << "a: " << a << endl | |
<< "b: " << b << endl | |
<< "c: " << c << endl | |
<< "d: " << d << endl | |
<< "e: " << e << endl | |
<< "f: " << f << endl | |
<< "g: " << g << endl | |
<< "h: " << h << endl; | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment