Bài tập C++/Cấu trúc lặp/Trăm trâu trăm cỏ

//Trăm trâu trăm cỏ

  1. include <iostream>

using namespace std;

int main() { for (int x(1); x <= 100; x++) { for (int y(1); y <= 100; y++) { for (float z(1); z < 100; z++) { if (x + y + z == 100 && 5 * x + 3 * y + z / 3 == 100) { cout << "So trau dung: " << x << '\n'; cout << "So trau nam: " << y << "\n"; cout << "So trau gia: " << z << '\n'; cout << '\n'; } } } }

return 0; }