C++版本百鸡问题1045

来源:互联网 发布:java已过时需要更新 编辑:程序博客网 时间:2024/06/04 20:08
#include "stdafx.h"#include<iostream>#include<string>using namespace std;int _tmain(int argc, _TCHAR* argv[]){int n;while (cin>>n){for (int x = 0; x <= 100; x++){for (int y = 0; y <= 100-x; y++){int z = 100 - x - y;if (x * 5 * 3 + y * 3 * 3 + z <= n * 3){cout << "x=" << x << "," << "y=" << y << "," << "z=" << z << endl;}}}}}


0 0
原创粉丝点击