`
cloverprince
  • 浏览: 127201 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

普通青年 文艺青年 2B青年

阅读更多
本文纯属搞笑,如有雷同,纯属巧合。

/* normal-youth.c */
main() {
        printf("hello world");
}


/* literature-youth.c */
int main(int argc, char** argv) {
    printf("Hello world!\n");
    return 0;
}


/* 2b-youth.c */
#define m main
#define p(x) printf(#x)
m(){p(hello world);}



// NormalYouth.java
public class NormalYouth {
    public static void sayHello(String name) {
        System.out.println("Hello, "+name);
    }
}



// LiteratureYouth.java

/**
 * Copyright 2011 Literature Youth
 *
 * Permission is granted to anyone who obtained a copy of this code.
 * You may
 *    use,
 *    compile,
 *    modify
 *    and/or redistribute this code
 * provided that you
 *    don't blame the Literature Youth for any consequences caused
 *    by using this code.
 */
package com.example.youth.literature.hello;

/**
 *  LiteratureYouth is a hello-saying object.
 */
public class LiteratureYouth {
    private String name;
    
    /**
     * Get the name to say hello to.
     * @return the name to say hello to.
     */
    public getName() { return name; }

    /**
     * Set the name to say hello to.
     * @param name the name to say hello to.
     */
    public setName(String name) { this.name = name; }

    /**
     * Construct a LiteratureYouth object that says hello to name.
     * @param name the name to say hello to.
     */
    public LiteratureYouth(String name) {
        super();
        this.name = name;
    }

    /**
     * Say hello to the pre-defined name.
     */
    public void sayHello() {
        System.out.println("Hello, "+name);
    }
}


// TwoBiYouth.java
public class TwoBiYouth {
    public static String name = "world";
    private static TwoBiYouth instance = new TwoBiYouth();
    public static TwoBiYouth getInstance() { return instance; }

    public interface SayHelloStrategy {
        void sayHello();
    }

    public class DefaultSayHelloStrategy implements SayHelloStrategy {
        @Override public void sayHello() {
            System.out.println("Hello, "+name);
        }
    }

    private SayHelloStrategy strategy = new DefaultSayHelloStrategy();
    public SayHelloStrategy getStrategy() { return strategy; }
    
    public static class TwoBiYouthVisitor {
        public void visit(TwoBiYouth tby) {
            tby.getStrategy().sayHello();
        }
    }

    public static class Facade {
        public void sayHello(String n) {
            TwoBiYouth.name = n;
            TwoBiYouth tby = TwoBiYouth.getInstance();
            TwoBiYouthVisitor visitor = new TwoBiYouthVisitor();
            visitor.visit(tby);
        }
    }
}


# normal-youth.sql
SELECT 'Hello world';


# literature-youth.sql
SELECT 'Hello', name FROM hw WHERE p = 'Hello';


// 2bYouth.sql.java
conn.createStatement().execute(
    "SELECT 'Hello', name FROM hw WHERE p = '"
         + scanner.next() + "';");



""" normal-youth.py """
def hello(name):
    print "Hello", name


""" literature-youth.py """
def hello(name):
    assert(sys.version_info.major == 2 and
           sys.version_info.minor >= 6 or
           sys.version_info.major > 2)
    print "Hello {}".format(name)


""" 2b-youth.py """
hello = lambda n : (lambda v: v + " " + n)("Hello")




#!/bin/bash
# normal-youth.sh

# calculate 1+2+...+100
SUM=0
for n in {1..100}; do
    SUM=$((SUM + n))
done
echo $SUM


#!/bin/bash
# literature-youth.sh

# calculate 1+2+...+100
for x in $(seq 100); do
    for y in $(seq $x); do
        echo $y 
    done
done | wc -l


#!/bin/bash
# 2b-youth.sh

# calculate 1+2+...+100
echo $((1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+100))



-- NormalYouth.hs
factorial 0 = 1
factorial n = n * fac (n-1)


-- LiteratureYouth.hs
factorial n = foldr (*) 1 [1..n]


-- 2bYouth.hs
module Main where

data Natural = Zero | Succ Natural deriving Show

one = Succ Zero
two = Succ one
three = Succ two
four = Succ three
five = Succ four
six = Succ five

a +++ Zero = a
a +++ Succ x = Succ a +++ x

a *** Zero = Zero
a *** Succ x = a +++ (a *** x)

factorial Zero = one
factorial n@(Succ x) = n *** factorial x

toi Zero = 0
toi (Succ x) = 1 + toi x



0
4
分享到:
评论
3 楼 cloverprince 2011-10-27  
沙舟狼客 写道
貌似2b青年的代码很有技术含量

嗯,简单问题复杂化。
2 楼 沙舟狼客 2011-10-27  
貌似2b青年的代码很有技术含量
1 楼 yangkuan 2011-10-26  
ZB青年,哈哈

相关推荐

Global site tag (gtag.js) - Google Analytics