Help us understand the problem. What is going on with this article?

# こういうダイエットアプリがほしい

More than 5 years have passed since last update.

# こういうダイエットアプリがほしい

⇒夜食の誘惑

## 解決策

```# include <Siv3D.hpp>

int foodToTime(String food);
String nameEatableFood(double kcal);
String nameNextFood(double kcal);

String food_name[] = { L"松屋のプレミアム牛めし", L"マクドナルドのハンバーガー", L"マクドナルドのチキンクリスプ", L"水", L"日高屋の中華そば", L"クラッシュタイプの蒟蒻畑ライト ぶどう味" };
double food_kcal[] = { 962.0, 275.0, 366.0, -0.01, 669.0, 39.0};
int kakin = 0;
double allowed_kcal = 0.1;
double kcal_per_sec = 0.0307;

void Main()
{
const Font font(14);

while (System::Update())
{
String food_name = nameEatableFood(allowed_kcal);
kcal_per_sec = 0.0307 + 0.1*kakin*kakin;
allowed_kcal += kcal_per_sec/60;
font(L"今なら", food_name, L"が食べられます。").draw(0, 0);
food_name = nameNextFood(allowed_kcal);
int next_time = foodToTime(food_name);
font(food_name, L"\nが食べられるのは", next_time, L"秒後です。").draw(0, 100);
font(DecimalPlace(3), allowed_kcal , L"kcal").draw(80,200);
Circle(400, 300, 40).draw(Palette::Orange);

if (((Mouse::Pos().x - 400)^2 + (Mouse::Pos().y - 300)^2) < 100 && Input::MouseL.clicked){
kakin++;
}
font(kakin, L"課金").drawCenter({ 400, 280 });
font(kcal_per_sec, L"kcal/sec").drawCenter({ 400, 320 });

}
}

int foodToTime(String food){
for (int i = 0; i < sizeof(food_name) / sizeof(food_name[0]); i++){
if (food_name[i] == food){
return (food_kcal[i] - allowed_kcal) / kcal_per_sec;
}
}
return 0;
}

String nameEatableFood(double kcal){

double return_kcal = -1.0;
String return_name;
for (int i = 0; i < sizeof(food_name) / sizeof(food_name[0]); i++){
if (food_kcal[i]>return_kcal && food_kcal[i] < kcal){
return_kcal = food_kcal[i];
return_name = food_name[i];
}
}
return return_name;
}

String nameNextFood(double kcal){

double return_kcal = 99999;
String return_name;
for (int i = 0; i < sizeof(food_name) / sizeof(food_name[0]); i++){
if (food_kcal[i]<return_kcal && food_kcal[i] > kcal){
return_kcal = food_kcal[i];
return_name = food_name[i];
}
}
return return_name;
}

```
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away