Facebook
From korayaaaa, 1 Month ago, written in Fortran.
Embed
Download Paste or View Raw
Hits: 197
  1. program ZarAtmaOyunu
  2.   implicit none
  3.   real :: oyuncuZar1, oyuncuZar2, sistemZar1, sistemZar2
  4.   integer :: toplamOyuncuZar, toplamSistemZar
  5.   character(20) :: komut
  6.  
  7.   ! Oyuncu için rastgele iki zar at
  8.   call random_seed()
  9.   call random_number(oyuncuZar1)
  10.   call random_number(oyuncuZar2)
  11.   oyuncuZar1 = 1 + int(6 * oyuncuZar1) ! 1 ile 6 arasında bir sayı
  12.   oyuncuZar2 = 1 + int(6 * oyuncuZar2) ! 1 ile 6 arasında bir sayı
  13.   toplamOyuncuZar = oyuncuZar1 + oyuncuZar2
  14.  
  15.   ! Sistem için rastgele iki zar at
  16.   call random_number(sistemZar1)
  17.   call random_number(sistemZar2)
  18.   sistemZar1 = 1 + int(6 * sistemZar1) ! 1 ile 6 arasında bir sayı
  19.   sistemZar2 = 1 + int(6 * sistemZar2) ! 1 ile 6 arasında bir sayı
  20.   toplamSistemZar = sistemZar1 + sistemZar2
  21.  
  22.   ! Oyuncunun komutunu al
  23.   print *, "Komut girin (örn. /zarat): "
  24.   read(*,*) komut
  25.  
  26.   ! Komut kontrolü
  27.   if (trim(komut) == "zarat") then
  28.     ! Sonuçları göster
  29.     print *, "Oyuncu Zarları?:"
  30.     print *, " ", oyuncuZar1
  31.     print *, " ", oyuncuZar2
  32.     print *, "Toplam: ", toplamOyuncuZar
  33.     print *, "Sistem Zarları?:"
  34.     print *, " ", sistemZar1
  35.     print *, " ", sistemZar2
  36.     print *, "Toplam: ", toplamSistemZar
  37.     if (toplamOyuncuZar > toplamSistemZar) then
  38.       print *, "KAZANDIN!!!"
  39.     else if (toplamOyuncuZar < toplamSistemZar) then
  40.       print *, "KAYBETTİN!!!"
  41.     else
  42.       print *, "Berabere!"
  43.     end if
  44.   else
  45.     print *, "Geçersiz komut!"
  46.   end if
  47. end program ZarAtmaOyunu
  48.