Hatena::ブログ(Diary)

UDONCHAN

November 30, 2008

[]RubyとかPerlとかゆるふわで困る

周りの大学院生がゆるゆるふわふわしていて,大変けまらしかったのでひねくれてみた.

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);
    }
}

ぬるぽがこわい