Skip to content

Commit a64390c

Browse files
committed
new file: main.go
1 parent cb19c93 commit a64390c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

go/r/main.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
)
7+
8+
func main() {
9+
r1 := (flag.Int("r1", -1, "the value of R1"))
10+
r2 := (flag.Int("r2", -1, "the value of R2"))
11+
r := (flag.Int("r", -1, "the value of R"))
12+
flag.Parse()
13+
if (-1 != *r) && (-1 != *r1) && (-1 != *r2) {
14+
fmt.Printf("(R R1)R2=%f\n(R1 R2)R=%f\n", float64((*r1)*(*r))/float64(*r1-*r), float64((*r1)*(*r2))/float64((*r1)+(*r2)))
15+
return
16+
}
17+
if (-1 == *r1) && (-1 != *r2) {
18+
*r1 = *r2
19+
*r2 = -1
20+
}
21+
if -1 == *r1 || ((-1 == *r) && (-1 == *r2)) {
22+
fmt.Printf("plz input args\n")
23+
return
24+
}
25+
if *r != -1 {
26+
fmt.Printf("R2=%f\n", float64((*r1)*(*r))/float64(*r1-*r))
27+
return
28+
}
29+
if *r2 != -1 {
30+
fmt.Printf("R=%f\n", float64((*r1)*(*r2))/float64((*r1)+(*r2)))
31+
return
32+
}
33+
}

0 commit comments

Comments
 (0)