xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

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

資源簡(jiǎn)介

我的自動(dòng)選菜程序,不用每天不知道吃什么菜了

資源截圖

代碼片段和文件信息

#include?
#include?
#include?

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

//?隨機(jī)數(shù)分布范圍是?[0-RAND_MAX]
//?每種食物的可能性為?1/(weight1+weight2+weight3+...+weightn)?*?100%
int?main(int?argcchar**argv)
{
//算出所有食物的權(quán)重和
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);
//算出每個(gè)食物的分布區(qū)間
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);
}

//種一個(gè)隨機(jī)數(shù)
srand(GetTickCount());
int?r?=?rand();
int?times?=?1;
if(?argc?>?1?)
times?=?atoi(argv[1]);
for(?int?i=0?;?i {
//種一個(gè)隨機(jī)數(shù)生成一個(gè)隨機(jī)數(shù)
srand(r);?r?=?rand();
printf(“today?rand?number?:?%d/%d\n“rRAND_MAX);
//查看落在哪個(gè)區(qū)間段
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;
}

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????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


評(píng)論

共有 條評(píng)論