November 30, 2008
■[プログラミング]RubyとかPerlとかゆるふわで困る
- 算数にチャレンジ!!第624回問題 - い〜さねっと
- 算数にチャレンジ!! 第624回問題 をRubyで解く - y_tsuda's blog - s21g
- 算数にチャレンジ! - はこべにっき@bkc - bkcグループ
- 算数にチャレンジの問題を解いてみた - まめ畑
周りの大学院生がゆるゆるふわふわしていて,大変けまらしかったのでひねくれてみた.
public class Mondai624 { public static void main(String args[]) { class Node { Integer val; Node next; Node (Integer val) { this.val = val; } } Node head = new Node(new Integer(0)); for (Node cur=head; !new Integer(512).equals(cur.val); cur=cur.next) cur.next = new Node(new Integer(cur.val.intValue()+1)); for (int i=0; head.next.next!=null; i++) if(i%2==0) for (Node cur=head; cur.next!=null; cur=cur.next) cur.next = cur.next.next; else for (Node cur=head.next; cur!=null; cur=cur.next) cur.next = cur.next.next System.out.println(head.next.val); } }
ぬるぽがこわい

