91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-16
  • 語言: 其他
  • 標簽: 小程序??

資源簡介

我的自動選菜程序,不用每天不知道吃什么菜了

資源截圖

代碼片段和文件信息

#include?
#include?
#include?

struct?t_food?{
char?name[128]; //食物名稱
double??weight; //食物的權重
double??range_from; //分布在隨機數取值范圍的空間?從
double??range_to; //分布在隨機數取值范圍的空間?到
}?food_list[128]?=?{
{“白菜“??1?0?0}?
{“茄子“??1?0?0}?
{“土豆“??1?0?0}?
{“紅薯“??5?0?0}?
{“雞蛋“??5?0?0}?
{““-1-1-1}
};

//?隨機數分布范圍是?[0-RAND_MAX]
//?每種食物的可能性為?1/(weight1+weight2+weight3+...+weightn)?*?100%
int?main(int?argcchar**argv)
{
//算出所有食物的權重和
double?totle_weight?=?0;
for(int?i=0;food_list[i].weight!=-1;i++){
totle_weight?+=?food_list[i].weight;
}
printf(“totle?weight?:?%4.4f\n“totle_weight);
//算出每個食物的分布區間
food_list[0].range_from?=?0;
food_list[0].range_to =?RAND_MAX*food_list[0].weight/totle_weight;
printf(“%s?:?from?:?%5.5f?->?%5.5f\n“food_list[0].namefood_list[0].range_fromfood_list[0].range_to);
for(int?i=1;food_list[i].weight!=-1;i++){
food_list[i].range_from?=?food_list[i-1].range_to;
food_list[i].range_to =?food_list[i-1].range_to?+?RAND_MAX*food_list[i].weight/totle_weight;
printf(“%s?:?from?:?%5.5f?->?%5.5f\n“food_list[i].namefood_list[i].range_fromfood_list[i].range_to);
}

//種一個隨機數
srand(GetTickCount());
int?r?=?rand();
int?times?=?1;
if(?argc?>?1?)
times?=?atoi(argv[1]);
for(?int?i=0?;?i {
//種一個隨機數生成一個隨機數
srand(r);?r?=?rand();
printf(“today?rand?number?:?%d/%d\n“rRAND_MAX);
//查看落在哪個區間段
for(int?i=0;food_list[i].weight!=-1;i++){
if(?(?food_list[i].range_from?<=?r?)?&&?(?r?<=?food_list[i].range_to?)?)
printf(“今天的食物是?:?%s\n“food_list[i].name?);
}
}

return?0;
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????1770??2010-01-19?15:46??autofood.cpp

?????文件?????????80??2010-01-19?15:47??makefile

?????文件????????239??2010-01-19?15:53??readme.txt

-----------?---------??----------?-----??----

?????????????????2089????????????????????3


評論

共有 條評論