Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOJ Utils #117

Open
hojongs opened this issue Jun 24, 2022 · 1 comment
Open

BOJ Utils #117

hojongs opened this issue Jun 24, 2022 · 1 comment

Comments

@hojongs
Copy link
Owner

hojongs commented Jun 24, 2022

Python

"""
n = int(readl())
nums = [int(i) for i in readl().split()]
nums = [int(readl()) for _ in range(n)]
lines = [readl().rstrip() for _ in range(n)]
rows = [[int(i) for i in readl().split()] for _ in range(n)]
s = readl().rstrip()
"""
import sys
readl = sys.stdin.readline

Go

readString

var reader = bufio.NewReader(os.Stdin)
var s string

func readString() {
	delim := "\n"
	if os.Getenv("OS") == "WINDOWS_NT" {
		delim = "\r\n"
	}
	s, _ = reader.ReadString('\n')
	s = strings.TrimSuffix(s, delim)
}

func main() {
	readString()
}

readInt

var reader = bufio.NewReader(os.Stdin)
var n int

func readInt(a *int) {
	fmt.Fscan(reader, a)
}

func main() {
	readInt(&n)
}

readIntArray

var reader = bufio.NewReader(os.Stdin)
var n int
var nums [10000]int

func readInt(a *int) {
	fmt.Fscan(reader, a)
}

func readIntArray(n int) {
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &nums[i])
	}
}

func main() {
	readInt(&n)
	readIntArray(n)
}

printlnIntArray

func printlnIntArray(nums []int, sep string) {
	num_strs := make([]string, len(nums))
	for i := 0; i < n; i++ {
		num_strs[i] = strconv.Itoa(nums[i])
	}
	fmt.Println(strings.Join(num_strs, sep))
}
@dangddoong
Copy link

당케

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants