ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/2947
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var arr = make([]int, 5)
fmt.Fscanln(reader, &arr[0], &arr[1], &arr[2], &arr[3], &arr[4])
for arr[0] != 1 || arr[1] != 2 || arr[2] != 3 || arr[3] != 4 || arr[4] != 5 {
for i := 0; i < 4; i++ {
if arr[i] > arr[i+1] {
arr[i], arr[i+1] = arr[i+1], arr[i]
for j := 0; j < 4; j++ {
fmt.Fprintf(writer, "%d ", arr[j])
}
fmt.Fprintf(writer, "%d\n", arr[4])
}
}
}
}
๐จ Python3
# https://www.acmicpc.net/problem/2947
import sys
if __name__ == "__main__":
arr = list(map(int, sys.stdin.readline().split()))
while arr[0] != 1 or arr[1] != 2 or arr[2] != 3 or arr[3] != 4 or arr[4] != 5:
for i in range(4):
if arr[i] > arr[i+1]:
arr[i], arr[i+1] = arr[i+1], arr[i]
print('{} {} {} {} {}'.format(arr[0], arr[1], arr[2], arr[3], arr[4]))
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 4573๋ฒ / Pizza Pricing [Go][Python3] (0) | 2020.12.22 |
---|---|
BOJ / 1392๋ฒ / ๋ ธ๋ ์ ๋ณด [Go][Python3] (0) | 2020.12.19 |
BOJ / 2468๋ฒ / ์์ ์์ญ [Go][Python3] (0) | 2020.12.16 |
BOJ / 2667๋ฒ / ๋จ์ง๋ฒํธ๋ถ์ด๊ธฐ [Go][Python3] (0) | 2020.12.15 |
BOJ / 11724๋ฒ / ์ฐ๊ฒฐ ์์์ ๊ฐ์ [Go][Python3] (0) | 2020.12.14 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ์๊ณ ๋ฆฌ์ฆ
- dfs
- ํ
- ballet
- python3
- BFS
- ํ๋ก์ด๋์์ฌ
- ๋ชฝ๊ณ ๋๋น
- ํด์๋งต
- java
- ์๋ฐ
- ๋งฅ๋ถ
- ๋ฐ๋
- ๋ฐฑ์ค
- dp
- Golang
- AWS
- Macbook pro 2012 mid 13
- BOJ
- ์ด๋ถํ์
- ๋ธ๋ฃจํธํฌ์ค
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ์คํ
- baekjoon
- ๋งฅ๋ถํ๋ก
- MongoDB
- ๋ถํ ์ ๋ณต
- ์๊ฐ๊ต์ฒด
- go
- Algorithm
- Total
- Today
- Yesterday