fork(2) download
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. #define K 10 // giá trị lá K
  7. #define J 10 // giá trị lá J
  8. #define Q 10 // giá trị lá Q
  9.  
  10.  
  11. int main(void)
  12. {
  13. srand(time(NULL));
  14. int laBai[13]={1,2,3,4,5,6,7,8,9,10,K,J,Q};
  15. int trangThai[13]={0}; // khỏi tạo toàn là 0,0,0,0,0,...
  16.  
  17. int nut_1 = 0; // số nút ng chơi 1
  18. int nut_2 = 0; // số nút ng chơi 2
  19.  
  20. int la=0; // la bai se phát
  21. for(int i=1; i<=3; i++)
  22. {
  23. //vào game.....
  24. printf_s("phat lan thu %d\n",i);
  25. //nếu đụng lá phát rồi có trạng thái = 1 thì dẹp..phát lại
  26. do
  27. {
  28. la = rand()%13;
  29. } while (trangThai[la]==1); // trạng thái lá bài thứ "la" đã phát rồi
  30. trangThai[la]=1; // cập nhật trạng thái cho lá bài đã phát thành 1
  31. nut_1=nut_1+laBai[la]; // cập nhật số nút
  32. printf_s("Phat cho nguoi thu 1 la: %d\n",la+1); // thông báo
  33.  
  34. do
  35. {
  36. la = rand()%13;
  37. } while (trangThai[la]==1);
  38. trangThai[la]=1;
  39. nut_2=nut_2+laBai[la];
  40. printf_s("Phat cho nguoi thu 2 la: %d\n",la+1);
  41.  
  42. }
  43. if(nut_1>nut_2) printf_s("Thang thu 2 tra tien nhau :v");
  44. else
  45. if(nut_1<nut_2) printf_s("Thang thu nhat tra tien nhau =))");
  46. else printf_s("Bang nhau...");
  47. _getch();
  48. return 0;
  49. }
  50.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:2:19: fatal error: conio.h: No such file or directory
compilation terminated.
stdout
Standard output is empty