Jackpot oyunu nedir?
? Jackpot oyunu 1'den 9'a kadar rastgele 3 sayı üretilip sayıların birbirine eşitliğine göre sonuca değerler verildiği basit bir oyundur. Bütün sayılar aynı ise 'Jackpot!', 2 sayı aynı ise 'iyi denemeydi', hiçbiri birbirinin eşiti değil ise 'kotu sans' sonucu oluşur.
Soru: C programlamada jackpot oyununu yazınız.
? Jackpot oyunu 1'den 9'a kadar rastgele 3 sayı üretilip sayıların birbirine eşitliğine göre sonuca değerler verildiği basit bir oyundur. Bütün sayılar aynı ise 'Jackpot!', 2 sayı aynı ise 'iyi denemeydi', hiçbiri birbirinin eşiti değil ise 'kotu sans' sonucu oluşur.
Soru: C programlamada jackpot oyununu yazınız.
Kod:
01.#include<stdio.h>
02.#include<conio.h>
03.#include<time.h>
04.#include<windows.h>
05.void gotoxy (int x, int y)
06.{
07. COORD coord; // coordinates
08. coord.X = x; coord.Y = y; // X and Y coordinates
09. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
10.}
11.void cerceve(int x1,int y1,int x2,int y2)
12.{
13. int i,j;
14. for(i=x1;i<=x2;i++)
15. {
16. gotoxy(i,y1); printf("%c",196);
17. gotoxy(i,y2); printf("%c",196);
18. }
19. for(j=y1;j<=y2;j++)
20. {
21. gotoxy(x1,j); printf("%c",179);
22. gotoxy(x2,j); printf("%c",179);
23. }
24. gotoxy(x1,y1); printf("%c",218);
25. gotoxy(x1,y2); printf("%c",192);
26. gotoxy(x2,y1); printf("%c",191);
27. gotoxy(x2,y2); printf("%c",217);
28.}
29.void jackpot()
30.{
31. cerceve(5,5,75,22);
32. cerceve(10,10,25,20);
33. cerceve(30,10,45,20);
34. cerceve(50,10,65,20);
35. int seed = time(NULL);
36. srand(seed);
37. int a=rand()%8+1;
38. int b=rand()%8+1;
39. int c=rand()%8+1;
40. gotoxy(15,15); printf("%d",a);
41. gotoxy(35,15); printf("%d",b);
42. gotoxy(60,15); printf("%d",c);
43. if((a==b)&&(b==c)){
44. gotoxy(30,7); printf("!! JACKPOT !!");
45. }
46. else if((a==b)||(b==c)||(a==c)){
47. gotoxy(30,7); printf("iyi denemeydi");
48. }
49. else {
50. gotoxy(30,7); printf("!!kotu sans!!");
51. }
52.}
53.main()
54.{
55. char tus;
56. do{
57. jackpot();
58. tus=getch();
59. }
60. while(tus!=27);
61.}
62.<stdio.h> </stdio.h>
63.<conio.h><time.h><windows.h>