㈠ 天氣預報說,在今後的三天中,每一天下雨的概率均為40%.現採用隨機模擬試驗的方法估計這三天中恰有兩天
由題意知模擬三天中恰有兩天下雨的結果,經隨機模擬產生了如下20組隨機數, 在20組隨機數中表示三天中恰有兩天下雨的有:191、271、932、812、393,共5組隨機數, ∴所求概率為
故選B. |
㈡ C語言編寫程序
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
intmain()
{
inttemperature;//溫度
intweather;//天氣
charstr_weather[5];
intwind;//風
srand((unsigned)time(0));//初始化隨機種子
temperature=rand()%63-20;//獲取-20到42的隨機數
while(1)
{
weather=rand()%3;//獲取天氣情況:0為雨,1為雪,2為晴
if(temperature<0&&weather==0)//如果溫度小於0度並且天氣為雨,則重新獲取
{
continue;
}
switch(weather)
{
case0:
strcpy(str_weather,"雨");
break;
case1:
strcpy(str_weather,"雪");
break;
case2:
strcpy(str_weather,"晴");
break;
}
break;//如果符合規則,則退出循環
}
wind=rand()%13;//獲取風級:0-12
printf("今天溫度:%d天氣:%s風級:%d級 ",temperature,str_weather,wind);
return0;
}
㈢ 天氣情況隨機公式
公式: =CHOOSE(INT(RAND()*4+1),"晴","陰","多雲","少雲")
㈣ excel 2007如何用已知天氣情況來判斷溫度,溫度生成隨機數。
在D:F列設置基礎數據
在B2中輸入或復制粘貼下列公式
=RANDBETWEEN(VLOOKUP(A2,D:F,2,),VLOOKUP(A2,D:F,3,))
或
=VLOOKUP(A2,D:F,2,)&"~"&VLOOKUP(A2,D:F,3,)
下拉填充