自吸泵压力罐安装视频:C编程问题

来源:百度文库 编辑:高考问答 时间:2024/04/27 13:50:29
有谁知道<计算机随机产生1—1000之间的一个整数,用户猜其大小,系统给出提示,告诉用户猜的数是大了还是小了,直到用户猜对为止,并给出猜的次数。>用C怎么编啊 ???

#include <stdio.h>
main(){
int i,k,j=0;
i = rand()%1000 + 1;
do{
j++;
printf ("Please enter the num you guess:(1-1000):\n");
scanf ("%d",&k);
if (i == k)
{
printf ("this is the %d,you right,the num is %d",j,k);
break;
}
else
{
printf ("this is the %d,you are wrong ,please enter the num again!\n");
scanf ("%d",&k);
}
} while (1);
}
不懂的话可以来我的群:13526460

#include "stdio.h"
#include"stdlib.h"
void main()
{int m,n,t=1;
while(1)
{m=random(1000);
if(m=!0)break;}
while(1)
{ printf("Please guess:\n");
scanf("%d",&n);
printf("\n");
if(m==n)
{printf("your are right! %d\n",t++);
break;}
else if(m>n)
printf("Error! your number is smaller %d\n",t++);
else if(m<n)

printf("Error! your number is bigger %d\n",t++);
}
}