Compare commits
No commits in common. "19717a5396fd4e7e3bea5a83f3cae1ee210eb2ca" and "c87729bc95f866bf65232eee1a4efc586c6b14e7" have entirely different histories.
19717a5396
...
c87729bc95
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 225 KiB |
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
|
@ -7,11 +7,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/", handler1)
|
http.HandleFunc("/", handler)
|
||||||
log.Fatal(http.ListenAndServe("localhost:8090", nil))
|
log.Fatal(http.ListenAndServe("localhost:8090", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func handler1(w http.ResponseWriter, r *http.Request) {
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "url.Path = %q \n", r.URL.Path)
|
fmt.Fprintf(w, "url.Path = %q \n", r.URL.Path)
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,8 +0,0 @@
|
||||||
package MaxCommFactor
|
|
||||||
|
|
||||||
func MaxComm(x, y int) int {
|
|
||||||
for y != 0 {
|
|
||||||
x, y = y, x%y
|
|
||||||
}
|
|
||||||
return x
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package conv
|
|
||||||
|
|
||||||
// CToF converts a Celsius temperature to Fahrenheit.
|
|
||||||
func CToF(c Celsius) Fahrenheit { return Fahrenheit(c*9/5 + 32) }
|
|
||||||
|
|
||||||
// FToC converts a Fahrenheit temperature to Celsius.
|
|
||||||
func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }
|
|
|
@ -1,16 +0,0 @@
|
||||||
// Package conv performs Celsius and Fahrenheit conversions.
|
|
||||||
package conv
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
type Celsius float64
|
|
||||||
type Fahrenheit float64
|
|
||||||
|
|
||||||
const (
|
|
||||||
AbsoluteZeroC Celsius = -273.15
|
|
||||||
FreezingC Celsius = 0
|
|
||||||
BoilingC Celsius = 100
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c Celsius) String() string { return fmt.Sprintf("%g°C", c) }
|
|
||||||
func (f Fahrenheit) String() string { return fmt.Sprintf("%g°F", f) }
|
|
|
@ -1,14 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Study/pkg/MaxCommFactor"
|
|
||||||
"Study/pkg/conv"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("AbsoluteZero:", conv.AbsoluteZeroC)
|
|
||||||
|
|
||||||
fmt.Println(conv.CToF(conv.BoilingC))
|
|
||||||
fmt.Println(MaxCommFactor.MaxComm(12, 24))
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Study/pkg/MaxCommFactor"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
var nums []int
|
|
||||||
var x, y int
|
|
||||||
for _, arg := range os.Args[1:] {
|
|
||||||
t, err := strconv.ParseInt(arg, 0, 64)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintln(os.Stderr, "cf:", err)
|
|
||||||
}
|
|
||||||
nums = append(nums, int(t))
|
|
||||||
}
|
|
||||||
if len(nums) <= 0 {
|
|
||||||
fmt.Println("Please input two numbers in console (one in a row)")
|
|
||||||
fmt.Scanln(&x, &y)
|
|
||||||
} else if len(nums) == 1 {
|
|
||||||
x = nums[0] // 将终端输入的数据赋值给x
|
|
||||||
fmt.Println("Please input one numbers in console (one in a row)")
|
|
||||||
fmt.Scanln(&y)
|
|
||||||
} else {
|
|
||||||
x, y = nums[0], nums[1]
|
|
||||||
}
|
|
||||||
fmt.Print(x, y, " Gcd is ", MaxCommFactor.MaxComm(x, y))
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
x := "hello"
|
|
||||||
for _, x := range x {
|
|
||||||
x := x + 'A' - 'a' // 将 for外部的x代入运算后 赋值给新局部变量x
|
|
||||||
fmt.Printf("%c", x) // "HELLO" (one letter per iteration)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue