--- /dev/null
+package main
+
+import (
+ "fmt"
+)
+
+type ErrNegativeSqrt float64
+
+func (e ErrNegativeSqrt) Error() string {
+ return fmt.Sprintf("cannot Sqrt negative number: %g\n", float64(e))
+}
+
+func Sqrt(x float64) (float64, error) {
+ z := 1.0
+ if x >= 0 {
+ for i := 0; i < 10; i++ {
+ z = z - (z*z-x)/(2*z)
+ }
+ } else {
+ return 0, ErrNegativeSqrt(x)
+ }
+ return z, nil
+}
+
+func main() {
+ fmt.Println(Sqrt(2))
+ fmt.Println(Sqrt(-2))
+}
has |
have |
had |
-go { printf("%s: is a verb\n", yytext); }
-[a-zA-Z]+ { printf("%s: is not a verb\n", yytext); }
-[0-9]+ { printf("%s: is a num\n", yytext); }
+go { printf("%s: is a verb", yytext); }
+[a-zA-Z]+ { printf("%s: is not a verb", yytext); }
+[0-9]+ { printf("%s: is a num", yytext); }
.|\n { ECHO; /* 通常的默认状态 */ }
%%
--- /dev/null
+#这是H1#
+##这是H2##
+###这是H3###
+#####这是H4####
+######这是H5#####
+######这是H6######
+
+vxcvzdfdsf
+fsadfasdf
+sfasdf
+
+> q adfads sdfads
+> fa
+> afdsfadfasdfasdfsadf
+> sfa
+> sdfasdf
+> fs fsadf
+> dsafsd
+> fsdfa
+> dsf
+> sadfasd
+
+
+这是一个*强调*示例,这是另一个 _强调_ 示例
+这是一个**加重强调**示例 或 __加重强调__
+这是一个***特别强调***示例 或 ___特别强调___
+
+
+这是个命令示例`echo "Hello World"` 输出什么?
+
+
+
+```
+#include <stdio.h>
+int main() {
+ printf("Hello, World\n");
+ return 0;
+}
+```
+
+以下是水平分割线
+* * *
+或
+***
+或
+*****
+或
+- - -
+
+链接
+[Hello](http://www.qq.com)
+or
+[Tag][Link]
+[Link]: http://www.qq.com "sfasd"
+
+
+
+
+
+
+