Created
February 3, 2018 10:53
-
-
Save d0mmie/8f95f9858615e0bcbeff58ac16344c54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
lengther := 0 | |
couter := 0 | |
data := [] string{} | |
//resData := [3][10] int{} | |
fmt.Print("Input length: ") | |
fmt.Scanf("%d", &lengther) | |
i := 0 | |
for i < lengther { | |
var temp string | |
fmt.Printf("Input student code %d : ", i+1) | |
fmt.Scanf("%s", &temp) | |
if (len(temp) != 3) { | |
fmt.Println("Please input only three digit") | |
} else { | |
data = append(data, temp) | |
i += 1 | |
} | |
} | |
//for j := 0; j < len(data); j++ { | |
// temp := data[j] % 10 | |
// temp2 := (data[j] % 100) / 10 | |
// temp3 := (data[j] % 1000) / 100 | |
// //fmt.Println(temp) | |
// resData[0][temp] = resData[0][temp] + 1 | |
// resData[1][temp2] = resData[1][temp2] + 1 | |
// resData[2][temp3] = resData[2][temp3] + 1 | |
//} | |
//for k := 0; k < 3; k++ { | |
// for l := 0; l < 10; l++ { | |
// //if (resData[k][l] > 1) { | |
// couter += (resData[k][l] / 2) | |
// //} | |
// } | |
//} | |
for j := 0; j < len(data); j++ { | |
for k := j; k < len(data); k++ { | |
if (k + 1) != len(data) { | |
if data[j][0] == data[k+1][0] || data[j][1] == data[k+1][1] || data[j][2] == data[k+1][2] { | |
couter += 1 | |
} | |
} | |
} | |
} | |
fmt.Println(couter) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment