| 赞 | 0  | 
 
| VIP | 7 | 
 
| 好人卡 | 1 | 
 
| 积分 | 1 | 
 
| 经验 | 4577 | 
 
| 最后登录 | 2023-11-6 | 
 
| 在线时间 | 169 小时 | 
 
 
 
 
 
Lv1.梦旅人 
	- 梦石
 - 0 
 
        - 星屑
 - 100 
 
        - 在线时间
 - 169 小时
 
        - 注册时间
 - 2007-8-12
 
        - 帖子
 - 203
 
 
 
 | 
	
 本帖最后由 心雪 于 2011-4-15 01:32 编辑  
 
1、- $gks = Win32API.new("user32","GetKeyState","l","i")
 
 - $a = $gks.call(123)
 
 - class << Graphics
 
 -   alias _heart_snow_update update
 
 -   def update
 
 -     if ($gks.call(123) != $a)
 
 -       exit
 
 -     end
 
 -     _heart_snow_update
 
 -   end
 
 - end
 
 
  复制代码 2、 
- class Array
 
 -   def max
 
 -     max = self[0]
 
 -     for i in self
 
 -       if max < i
 
 -         max = i
 
 -       end
 
 -     end
 
 -     return i
 
 -   end
 
 - end
 
  
- p [1,3,5,6,7].max
 
  复制代码 3、好吧我承认我没研究出来 
 
4、 
- class SpriteEX < Sprite
 
 -   def initialize
 
 -     super
 
 -     @sx = 0
 
 -     @sy = 0
 
 -   end
 
 -   def x
 
 -     return @sx
 
 -   end
 
 -   def y
 
 -     return @sy
 
 -   end
 
 -   def x=(x)
 
 -     @sx = x
 
 -     super(@sx)
 
 -   end
 
 -   def y=(y)
 
 -     @sy = y
 
 -     super(@sy)
 
 -   end
 
 - end
 
 - $abc = SpriteEX.new
 
 - $abc.bitmap = RPG::Cache.icon("001-Weapon01")
 
 - for i in 1..10
 
 -   $abc.x = 0.5 + $abc.x
 
 -   Graphics.update
 
 - end
 
 
  复制代码 5、 
nil.__send__("66") 
 
6、理论神马的最讨厌了,明明p出来都是"method" 
-------------------------- 
好吧我竟然忘了defined?也可以判断常量- - 
 
7、 
- array_bitmaps = [RPG::Cache.icon("001-Weapon01"),RPG::Cache.icon("002-Weapon02"),RPG::Cache.icon("003-Weapon03")]
 
 - max = 0
 
 - maxi = 0
 
 - for i in 0...array_bitmaps.size
 
 -   bitmap = array_bitmaps[i]
 
 -   if bitmap.height * bitmap.width > max
 
 -     max = bitmap.height * bitmap.width
 
 -     maxi = i
 
 -   end
 
 - end
 
 - array_bitmaps[maxi].dispose
 
 - array_bitmaps[maxi] = nil
 
 - GC.start
 
 
  复制代码 8、没时间了……DFS+剔除23在一起的情况 
 
9、(请勿在RM中测试) 
- require "mathn.rb"
 
 - pr = Prime.new
 
 - pr.each{|v| break if v > 1000;p v ;}
 
  复制代码 至于说算法……- #include<stdio.h>
 
 - char a[1001]={0};
 
 - int kill_number(long n)
 
 - {
 
 - int i = 2;
 
 - while(i*n <= 1000)
 
 - {
 
 - a[i*n] = 1;i++;
 
 - } 
 
 - }
 
 - main()
 
 - {
 
 - long i,result = 0;
 
 - for(i=2;i<=1000;i++)
 
 - if(a[i] == 0)
 
 - kill_number(i);
 
 - for(i=2;i<=1000;i++)
 
 - if(a[i] == 0)
 
 - result++;
 
 - printf("%ld\n",result);
 
 - system("pause");
 
 - }
 
  
  复制代码 时间原因先用以前写好的C语言的玩意吧……有时间再改成Ruby 
 
为什么要追求一行代码呢~难道您打算参加国际Ruby混乱代码大赛? |   
 
 
 
 |