普通青年 文艺青年 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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值