急求高手帮忙写个C 程序

来源:百度知道 编辑:UC知道 时间:2024/05/21 22:51:22
利用随机函数生成1---N之间的一个整数,输入数字猜该数,每次提示输入的数字与生成的数字之间的大小关系,并统计猜数的次数;猜中后显示该数、猜数的次数及等级(三次以内为优秀,七次以内为良好,否则为不及格)。
帮忙写个C 程序
能把具体的代码写出来么 我是刚刚接触这个 不太会
能不能帮忙写个完整的

#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main()
{
int rand,n,a,times=1;
srand(time(NULL));
printf("enter N:\n");
scanf("%d",&n);
rand=random()%n;
printf("enter your anwser:");
scanf("%d",&a);
while(a!=rand)
{
if(a>rand)
printf("wrong!\nenter a smaller number:");
else if(a<rand)
printf("wrong!\nenter a bigger number:");
times++;
scanf("%d",&a);
}
if(times<3)
printf("times is %d\nPerfect!\n",times);
else if(times<7)
printf("times is %d\nGood!\n",times);
else
printf("times is %d\nCome on!\n",times);
return 0;
}

这么简单的程序,最好自己写.
可以提供几个关键的东东.
#include "time.h"

rand()

现写的测试通过,怎么说不完整呀,已经可以正确运行了还说不完整???????????????????????