Danny's profile季节的水滴PhotosBlogListsMore Tools Help

Blog


    3/8/2007

    号称一女程序员的强贴

    result love(boy, girl)
    {
        if( boy.有房() and boy.有车() )
        {
            boy.set(nothing);
            return girl.嫁给(boy);
        }
        if( girl.愿意等() )
        {
        while(!(boy.赚钱 > 100,000 and girl.感情 > 8 ) )
        {
            for( day=1; day <=365; day++)
            {
                if( day == 情人节 )
                if( boy.givegirl(玫瑰) )
                    girl.感情++;
                else
                    girl.感情--;  
                if( day == girl.生日 )
                if( boy.givegirl(玫瑰) )
                {
                    girl.感情++;
                else
                    girl.感情--;
                    boy.拼命赚钱();
                }
            }
            if( boy.有房() and boy.有车() )
            {
                boy.set(nothing);
                return girl.嫁给(boy);
            }
            年龄++;
            girl.感情--;
        }
        return girl.goto( another_boy);
    }
     

    3/6/2007

    两道简单的java题

    1.用1,2,2,3,4,5,这六个数字,用java写一个main函数,打印出所有不同的排列,如:512234,412345等,要求:“4”不能排第3位,“1”与“5”不能相连。
    2.数字a=11,b=4,不用第3个变量怎样把啊a和b的位置互换。
     
    第一题没有搞出来,第二题有以下几种方法:
    public class A{
        public static void main(String[] args){
            int a=11;
            int b=4;
            System.out.println("a:"+a+"\nb:"+b);
            a=a+b;
            b=a-b;
            a=a-b;
            System.out.println("互换后为:");
            System.out.println("a:"+a+"\nb:"+b);
        }
    }
     
    public static void main(String[] args) throws IOException{
    int a = 11;
    int b = 8;
    a = a^b;
    b=a^b;
    a=a^b;
    System.out.println(a);
    System.out.println(b);
    }
     
    class B{
     public static void main(String args[])
     {
       int a,b;
       a=10;
       b=8;
       System.out.println("交换之前的a与b是:"+a+","+b);
       b=a+(a=b)*0; //a与b的交换
       System.out.println("交换之后的a与b是:"+a+","+b);
     }
     
    class C
    {
    public static void main(String[] args)
    {
    int a=11;
    int b=4;
    a=~a & 0x0f;
    b=~b & 0x0f;
    System.out.println("a="+a);
    System.out.println("b="+b);
    }
    }