Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
var f int = 0
var index int
reader := bufio.NewReader(os.Stdin)
x, _ := reader.ReadString('\n')
// convert CRLF to LF
x = strings.Replace(x, "\n", "", -1)
y, _ := reader.ReadString('\n')
// convert CRLF to LF
y = strings.Replace(y, "\n", "", -1)
for index, _ = range x {
if x[index] == y[0] {
f = 1
for i, _ := range y {
if x[index+i] != y[i] {
f = 0
break
}
}
}
if f == 1 {
break
}
}
if f == 1 {
fmt.Print(index)
} else {
fmt.Print("-1")
}
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more