0

Can somebody help me with Match Results the course is go

My code package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} int a,b; int w,l,d; if(a>b){ fmt.Println("w") } else if(a<b){ fmt.Println("l") } else{ fmt.Println("d") } }

15th Jul 2021, 3:19 PM
Michael smith
Michael smith - avatar
10 Réponses
+ 4
package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} score := 0 var lastres string fmt.Scanln(&lastres) results = append(results, lastres) for _, v := range results { switch v { case "w": score += 3 case "d": score += 1 } } fmt.Println(score) }
17th Nov 2021, 4:40 PM
jturn
0
Try to explain well
4th Aug 2021, 12:55 PM
Fatoki Temiloluwa
0
Give answer
4th Aug 2021, 1:18 PM
Michael smith
Michael smith - avatar
0
You are making a program to analyze sport match results and calculate the points of the given team. The match results are stored in an array called results. Each match has one of the following results: "w" - won "l" - lost "d" - draw A win adds three points, a draw adds one point, and a lost match does not add any points. Your program needs to take the last match result as input and append it to the results array. After that, calculate and output the total points the team gained from the results.
9th Aug 2021, 6:45 PM
Michael smith
Michael smith - avatar
0
here is the answer to that question:- package main import ( "fmt" ) func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} var a,b int; var first string; a = 0; fmt.Scanln(&first) ; results = append(results, first) for b =0; b<len(results); b++ { dataResult := results[b]; if (dataResult == "w"){ a= 3 +a; }else if(dataResult =="d"){ a= 1 +a; } } fmt.Println(a) }
12th Nov 2021, 5:25 PM
nikhil upadhyay
0
package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} score := 0 var lastres string fmt.Scanln(&lastres) results = append(results, lastres) for _, v := range results { switch v { case "w": score += 3 case "d": score += 1 } } fmt.Println(score) }package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} score := 0 var lastres string fmt.Scanln(&lastres) results = append(results, lastres) for _, v := range results { switch v { case "w": score += 3 case "d": score += 1 } } fmt.Println(score) }
4th Apr 2022, 7:20 AM
ASRAR
ASRAR - avatar
0
package main import "fmt" /* win = 3 draw = 1 lost = 0 */ func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} score := 0 var input string fmt.Scanln(&input) results = append(results, input) for _, v := range results { if v == "w" { score += 3 } if v == "d" { score += 1 } } fmt.Println(score) }
26th Jul 2022, 5:06 PM
Fernando Alves
Fernando Alves - avatar
0
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) }
18th Sep 2022, 6:50 AM
Kanisak Shakya
Kanisak Shakya - avatar
0
package main import "fmt" func calc(s... string) { var scores = map[string]int{"w":3, "d": 1, "l": 0} var sum int for _, i := range s { sum += scores[i] } fmt.Println(sum) } func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} var l string fmt.Scanln(&l) results = append(results, l) calc(results...) }
19th Feb 2023, 2:55 PM
Luis Pirir
Luis Pirir - avatar
- 2
Explain the question better thats what i mean
4th Aug 2021, 1:59 PM
Fatoki Temiloluwa