寻求c语言高手!!帮忙编写简单的程序!!!!

来源:百度知道 编辑:UC知道 时间:2024/09/23 11:55:45
简单程序编写:

猜数游戏:程序要求学生用随机函数产生一个数,判断用户是否猜对,如果猜错了,则提示偏大还是偏小,记录用户猜数所用的时间和次数

帮忙下编写一下,谢谢了,好了我就追加分,,谢谢你们!!
我晕,下面的2位朋友,我用了VC6。0检查了下你们帮我编写的程序,一个有3个错误,另一个有8个错误

#include <stdio.h>
int main()
{
int n,count=0;

randomiz();
int a=rand()%10000;

while (1)
{
printf("请输入一个10000内的数:");
scanf("%d", &n);
if (n > a)
printf("大了.\n");
else if (n < a)
printf("小了.\n");
else
{
printf("正确了。\n");
break;
}

count++
}
printf("一共输入了%d次.", count);
getchar();
}

#include<iostream.h>
#include <stdlib.h>
#include <time.h>
void main()
{
int a,b=-1,i=1;
srand(time(0));
a=rand()%100;
cout<<"insert your number"<<endl;
cin>>b;
while(a!=b)
{if(a>b) cout<<"too small"<<endl;
if(a<b) cout<<"too big"<<endl;
i++;
cout<<"insert your number again"<<endl;
cin>>b;