Friday, May 4, 2012

math.random 사용예

   
 do  
           print(); print("***** RANDOM *****")  
             
           local a, b, c, d  
           a = math.random()  
           print("random() = " .. a)  
           a = math.random()  
           print("random() = " .. a)  
           a = math.random()  
           print("random() = " .. a)  
   
           b = math.random(10)  
           print("random(10) = " .. b)            
           b = math.random(10)  
           print("random(10) = " .. b)            
           b = math.random(10)  
           print("random(10) = " .. b)            
           b = math.random(10)  
           print("random(10) = " .. b)            
           b = math.random(10)  
           print("random(10) = " .. b)            
           b = math.random(10)  
           print("random(10) = " .. b)            
           b = math.random(10)  
           print("random(10) = " .. b)            
   
           c = math.random(10, 20)  
           print("random(10, 20) = " .. c)  
           c = math.random(10, 20)  
           print("random(10, 20) = " .. c)  
           c = math.random(10, 20)  
           print("random(10, 20) = " .. c)  
           c = math.random(10, 20)  
           print("random(10, 20) = " .. c)  
           c = math.random(10, 20)  
           print("random(10, 20) = " .. c)  
           c = math.random(10, 20)  
           print("random(10, 20) = " .. c)  
           c = math.random(10, 20)  
           print("random(10, 20) = " .. c)  
   
           math.randomseed(1234)  
           print("randomseed(1234)")  
           d = math.random(10)  
           print("random(10) = " .. d)            
           d = math.random(10)  
           print("random(10) = " .. d)            
           d = math.random(10)  
           print("random(10) = " .. d)            
   
           math.randomseed(1234)  
           print("randomseed(1234)")  
           d = math.random(10)  
           print("random(10) = " .. d)            
           d = math.random(10)  
           print("random(10) = " .. d)            
           d = math.random(10)  
           print("random(10) = " .. d)            
   
           math.randomseed(100)  
           print("randomseed(100)")  
           d = math.random(10)  
           print("random(10) = " .. d)            
           d = math.random(10)  
           print("random(10) = " .. d)            
           d = math.random(10)  
           print("random(10) = " .. d)            
             
           math.randomseed( os.time() )  
           print("randomseed(os.time())")  
           d = math.random(10)  
           print("random(10) = " .. d)            
           d = math.random(10)  
           print("random(10) = " .. d)            
           d = math.random(10)  
           print("random(10) = " .. d)  
 end  

No comments:

Post a Comment