c语言简单编程 求解答

guess the number (1 points)
• Define a number between one and one hundred
• If a user input a number, the computer output “Too high!” or
“Too low!”
• If you guess the number in 6 tries, print “That’s Correct!” • If not, print “Sorry, bye bye~”图片说明

#define NUM 12
printf("I'm thinking of a number between and including 1 to 100\n");
printf("Can you guess the number in 6 tries?\n");
for( int i= 0;i < 6;++i)
{
printf("Enter guess number %d:",i+1);
int inputNum;
scanf("%d",&inputNum);
if( inputNum > NUM )
printf("Too high!\n");
else if( inputNum < NUM )
printf("Too low!\n");
else
{
printf("That's Corrent!\n");
break;
}
}

#include <stdio.h>
#include <time.h>

//生成一个1 - 100 的随机值
int GetRandNum(void)
{
    srand((unsigned int)time(0));

    return (rand()%100) + 1;
}

//猜测系统生成的随机数
void GuessSysRandNum()
{
    int a = GetRandNum();
    int i = 1;
    int b;
    while(i < 7)
    {
        printf("Enter guess number %d:", i);
        scanf("%d", &b);
        if(a > b)
        {
            printf("Too low!\n");
        }
        else if(a < b)
        {
            printf("Too high!\n");
        }
        else
        {
            printf("That's Correct!\n");
            return;
        }
        i++;
    }
    printf("Sorry, bye bye ~\n");
}

int main(void)
{
    GuessSysRandNum();

    return 0;
}