/*源程序:exp4_12(2).cpp*/
#include<stdio.h>
#include<stdlib.h>
void main()
{
int r;
int g;
r=rand();
printf("input a number:");
scanf("%d",&g);
if(g==r)
printf("right!\n");
else
printf("the number is:%d,you are wrong!\n",r);
}
#include<stdio.h>
#include<stdlib.h>
void main()
{
int r;
int g;
r=rand();
printf("input a number:");
scanf("%d",&g);
if(g==r)
printf("right!\n");
else
printf("the number is:%d,you are wrong!\n",r);
}
![](https://img-my.csdn.net/uploads/201303/17/1363502216_7898.jpg)