Traditional Culture Encyclopedia - Weather inquiry - C language programming
C language programming
#include?
#include?
#include?
int?main()
{
int?temperature;?//temperature
int?weather;?//weather
char?str_weather[5];
int?wind;?//Wind
srand((unsigned)time(0));//Initialize random seed?< /p>
temperature=rand()%63-20;?//Get a random number from -20 to 42?
while(1)
{
weather=rand()%3;//Get the weather conditions: 0 is rain, 1 is snow, 2 is sunny
if(temperature<0?&&?weather==0)? //If the temperature is less than 0 degrees and the weather is rainy, reacquire
{
continue;
}
switch(weather )
{
case?0:
strcpy(str_weather,"Rain");
break;
< p> case?1:strcpy(str_weather,"snow");
break;
case?2:
strcpy (str_weather,"Qing");
break;
}
break;?//If the rules are met, exit the loop?
< p> }wind=rand()%13;//Get wind level: 0-12?
printf("Today's temperature: %d? Weather: %s? Wind Level: %d level\n",temperature,str_weather,wind);
return?0;
}
- Related articles
- Tips for temple bay island Tourism
- 20 14 smog weather statistics in Beijing
Question 1:C
Question 2:C
Test analysis:
Question 1: Beijing is located on the northern edge of North China Plain, bordering Yanshan Mo
- Subtropical monsoon and humid climate are mainly distributed in _ _ _
- How does Chen Menglei sing Shen Yang?
- Ask if there is a squeak when the car brakes.
- The Origin, Time and Customs of Qingming Festival
- Can humans predict the weather or not?
- How should friends in the south fight against cold and humid weather?
- What's the weather like in Sanya and Haikou recently? What kind of clothes are suitable for wearing? Recommend Sanya attractions!
- How many kinds of door gods are there? What are they?