This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 文字列版take | |
void take_char(int n, char* string, char* substring) { | |
int i; | |
for (i = 0; i < n; i++) { | |
substring[i] = string[i]; | |
} | |
substring[i+1] = '\0'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int sum(const int num[],const int count,const int result){ | |
if (count == 0) { | |
return result + num[count]; | |
} else { | |
sum(num,(count-1),(result + num[count])); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn fizzbuzz | |
"fizzbuzz" | |
[x] | |
(cond (and (= (mod x 3) 0) | |
(= (mod x 5) 0)) "Fizz Buzz" | |
(= (mod x 3) 0) "Fizz" | |
(= (mod x 5) 0) "Buzz" | |
:else x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns grimoire.jcurses | |
(:import (jcurses.system CharColor) | |
(jcurses.widgets DefaulLayoutManager) | |
(jcurses.widgets WidgetsConstants) | |
(jcurses.widgets Window))) | |
(def lbl | |
(doto | |
(Label. | |
"All gone to hell!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object fibonacci { | |
def main(args: Array[String]) { | |
var fibonacci = List(1,1) | |
while(fibonacci.length < args(0).toInt) { | |
fibonacci = fibonacci :+ fibonacci.takeRight(2).sum | |
} | |
println(fibonacci.apply(args(0).toInt - 1)) |
NewerOlder