Facebook
From Koray [RAY], 1 Month ago, written in Fortran.
Embed
Download Paste or View Raw
Hits: 145
  1. program ZarAtmaOyunu
  2.   implicit none
  3.   real :: oyuncuZar1, oyuncuZar2, sistemZar1, sistemZar2
  4.   integer :: toplamOyuncuZar, toplamSistemZar
  5.   character(20) :: komut
  6.  
  7.   ! Oyuncu ve sistem için rastgele iki zar atma
  8.   call random_number(oyuncuZar1)
  9.   call random_number(oyuncuZar2)
  10.   call random_number(sistemZar1)
  11.   call random_number(sistemZar2)
  12.   oyuncuZar1 = 1 + int(6 * oyuncuZar1)
  13.   oyuncuZar2 = 1 + int(6 * oyuncuZar2)
  14.   sistemZar1 = 1 + int(6 * sistemZar1)
  15.   sistemZar2 = 1 + int(6 * sistemZar2)
  16.   toplamOyuncuZar = oyuncuZar1 + oyuncuZar2
  17.   toplamSistemZar = sistemZar1 + sistemZar2
  18.  
  19.   ! Sonuçları gösterme
  20.   print *, "Senin attığın:"
  21.   print *, " ", oyuncuZar1
  22.   print *, " ", oyuncuZar2
  23.   print *, "Toplam: ", toplamOyuncuZar
  24.   print *, "Sistemin attığı:"
  25.   print *, " ", sistemZar1
  26.   print *, " ", sistemZar2
  27.   print *, "Toplam: ", toplamSistemZar
  28.   if (toplamOyuncuZar > toplamSistemZar) then
  29.     print *, "KAZANDIN!!!"
  30.   else if (toplamOyuncuZar < toplamSistemZar) then
  31.     print *, "KAYBETTİN!!!"
  32.   else
  33.     print *, "Berabere!"
  34.   end if
  35. end program ZarAtmaOyunu
  36.