- 2
Can anyone solve Match Results problem in Golang course
9 odpowiedzi
+ 11
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)
}
I just solved it😊
+ 2
Yervand bro your solution Is working. Thank you sooooo much......
+ 2
😊
+ 2
package main
import "fmt"
func main() {
results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"}
var i string
fmt.Scanln(&i)
results = append(results, i)
res := 0
for _, v := range results {
switch v {
case "w":
res += 3
case "l":
res += 0
case "d":
res += 1
}
}
fmt.Println(res)
// I just solved it😊
}
0
what is the code for match results
0
package main
import "fmt"
func main() {
results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"}
Countpoints := 0
var input string
fmt.Scanln(&input)
results = append(results, input)
for _, i:= range results {
if i == "w" {
Countpoints += 3
} else if i == "d" {
Countpoints += 1
} else {
Countpoints = Countpoints
}
}
fmt.Println(Countpoints)
}
0
package main
import "fmt"
func main() {
results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"}
var s string
fmt.Scanln(&s)
results = append(results, s)
sum := 0
for _, v := range results {
switch v {
case "w":
sum += 3
case "d":
sum ++
}
}
fmt.Println(sum)
}
- 3
Many people can but they can help you.
No one will give the solution to just copy and paste
Or else show your try
- 3
Hello 💪
The Q&A is just for quest PROGRAMMING question,so dont spam it is annoying
We dont do the homerwork of others 👍
Also,check the SoloLearn forum for understand the rules
https://www.sololearn.com/discuss/1316935/?ref=app