Вопрос скорее будет звучать "как много могли съесть толстяки?".
#include <iostream>
using namespace std;
int main() {
int multiplier = 1;
float weightCake = 0;
float t1(0), t2(0), t3(0);
float t1Cakes(0), t2Cakes(0), t3Cakes(0);
cout << "Weight of cake, fat people 1-3: ";
cin >> weightCake; cin >> t1; cin >> t2; cin >> t3;
while(1) {
t1Cakes = multiplier * weightCake * 1;
if(t1Cakes > t1/2) {
cout << multiplier - 1;
break;
}
t2Cakes = multiplier * weightCake * 2;
if(t2Cakes > t2/2) {
t3Cakes = multiplier * weightCake * 4;
if(t3Cakes > t3/2) {
++multiplier;
x1, y1, x2, y2, x3, y3 - координаты точек треугольника, x, y - координаты точки.
Найдем векторное произведение, которое равно удвоенной площади треугольника.
Исходный код:
#include <iostream>
using namespace std;
int main() {
int x1, y1, x2, y2, x3, y3, x, y;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x >> y;
if (abs((x1 - x) * (y2 - y) - (x2 - x) * (y1 - y)) +
abs((x1 - x3) * (y - y3) - (x - x3) * (y1 - y3)) +
abs((x - x3) * (y2 - y3) - (x2 - x3) * (y - y3)) ==
abs((x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)))
{
cout << "In";
} else {
cout << "Out";
}
return 0;
}
Вопрос скорее будет звучать "как много могли съесть толстяки?".
#include <iostream>
using namespace std;
int main() {
int multiplier = 1;
float weightCake = 0;
float t1(0), t2(0), t3(0);
float t1Cakes(0), t2Cakes(0), t3Cakes(0);
cout << "Weight of cake, fat people 1-3: ";
cin >> weightCake; cin >> t1; cin >> t2; cin >> t3;
while(1) {
t1Cakes = multiplier * weightCake * 1;
if(t1Cakes > t1/2) {
cout << multiplier - 1;
break;
}
t2Cakes = multiplier * weightCake * 2;
if(t2Cakes > t2/2) {
cout << multiplier - 1;
break;
}
t3Cakes = multiplier * weightCake * 4;
if(t3Cakes > t3/2) {
cout << multiplier - 1;
break;
}
++multiplier;
}
}