+ 2
Match Results
Here package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} var a int var b string fmt.Scanln(&b) //results = append (results, results[(len(results)-1)]) results = append (results, b) for _, v := range results { switch { case v == "w": a += 3 case v == "l": a += 0 case v == "d": a += 1 } } fmt.Println(a) }
5 Antworten
+ 4
And why is there a case for lost? This gives no points. There is no reason to do this.
+ 1
What's your problem or question here. Please specify it firstly.
Happy coding!
+ 1
Schawnnara Jiri Jeena-Myrr
What is the problem here? It is working fine.
+ 1
package main
import "fmt"
func main() {
var (
lastRes []rune
total uint8
)
results := []rune{'w', 'l', 'w', 'd', 'w', 'l', 'l', 'l', 'd', 'd', 'w', 'l', 'w', 'd'}
var tmp string
fmt.Scanln(&tmp)
lastRes = []rune(tmp)
results = append(results, lastRes...)
for _, v := range results {
switch {
case v == 119:
total += 3
case v == 100:
total += 1
}
}
fmt.Println(total)
}
+ 1
package main
import "fmt"
func main() {
results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"}
var a int
var b string
fmt.Scanln(&b)
results = append (results, b)
for _, v := range results {
if v=="w"{
a+=3
}
if v=="d"{
a+=1
}
if v=="l"{
a+=0
}
}
fmt.Println(a)
}