1. #include <stdio.h>
int main(void)
{
unsigned int hours;
scanf("%u", &hours);
if(hours >= 0 && hours < 6)
printf("Ночь.");
else if(hours >= 6 && hours < 12)
printf("Утро.");
else if(hours >= 12 && hours < 18)
printf("День.");
else if(hours >= 18 && hours < 0)
printf("Вечер.");
return 0;
}
2. #include <stdio.h>
#include <stdlib.h>
#include <time.h>
unsigned int
chance = 3, enter;
srand(time(NULL));
while(chance > 0)
printf("Вы загадали число %d? 1 - да, 0 - нет\n", rand() % 5 + 1);
scanf("%u", &enter);
if(enter == 1)
printf("Ура!!!\n");
break;
printf("Жаль :(\n");
chance--;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
1. #include <stdio.h>
int main(void)
{
unsigned int hours;
scanf("%u", &hours);
if(hours >= 0 && hours < 6)
printf("Ночь.");
else if(hours >= 6 && hours < 12)
printf("Утро.");
else if(hours >= 12 && hours < 18)
printf("День.");
else if(hours >= 18 && hours < 0)
printf("Вечер.");
return 0;
}
2. #include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
unsigned int
chance = 3, enter;
srand(time(NULL));
while(chance > 0)
{
printf("Вы загадали число %d? 1 - да, 0 - нет\n", rand() % 5 + 1);
scanf("%u", &enter);
if(enter == 1)
{
printf("Ура!!!\n");
break;
}
printf("Жаль :(\n");
chance--;
}
return 0;
}