#include <stdio.h>
#include <stdlib.h>
#include<time.h>
int main()
{
int sotoida;
int i=0;
printf("MENU\n");
printf("Chon che do choi mot nguoi hoac hai nguoi\n");
printf("Moi ban chon che do 1 nguoi choi\n");
printf("1 : 1 - 100 \n");
printf("2 : 1 - 1000 \n");
printf("3 : 1 - 10000 \n");
printf("Moi ban an 4 che do 2 nguoi choi\n");
scanf("%d", &sotoida);
int sobimat = 0, sohientai=0;
switch(sotoida)
{
case 1:
printf("ban da chon che do nguoi choi muc de\n");
srand(time(NULL));
sobimat=(rand()%(100)+1);
break;
case 2:
printf("ban da chon che do 1 nguoi choi muc trung binh\n");
srand(time(NULL));
sobimat=(rand()%(1000)+1);
break;
case 3:
printf("ban da chon che do mot nguoi choi muc kho\n");
srand(time(NULL));
sobimat=(rand()%(10000)+1);
break;
case 4:
printf("che do 2 nguoi choi\n");
printf("nhap vao so bi mat: ");
scanf("%d",&sobimat);
break;
default:
printf("Khong co muc nao duoc chon!");
return 0;
break;
}
//Tao so tu nhien
//Vong lap ct tu dung khi tim dc so bi mat
do
{
i++;
printf("So can tim la bao nhieu ?");
scanf("%d",&sohientai);
//so sanh so hien tai voi so bi mat
if(sobimat>sohientai)
printf("lon hon !\n");
else if(sobimat<sohientai)
printf("nho hon!\n");
else
printf("Chuc mung ban da tim duoc so bi mat trong %d lan doan !!!\n",i);
}while(sohientai!=sobimat);
return 0;
}
lúc nào ah rảnh thì chỉ e với, e vẫn chưa làm đc :((