Created
May 12, 2022 20:34
-
-
Save jtprogru/7abe8ecd235679e08821db64e43fe873 to your computer and use it in GitHub Desktop.
Сначала задано число N — количество элементов в массиве (1≤N≤100). Далее через пробел записаны N чисел — элементы массива. Массив состоит из целых чисел. Необходимо вывести все элементы массива с чётными индексами.
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() { | |
var inputNumber int | |
var outputStr string | |
_, _ = fmt.Scan(&inputNumber) | |
inputArray := make([]int, inputNumber) | |
_, _ = fmt.Scan(&inputArray) | |
for i := 0; i < inputNumber; i++ { | |
_, _ = fmt.Scan(&inputArray[i]) | |
} | |
for k, v := range inputArray { | |
if k%2 == 0 { | |
outputStr += fmt.Sprintf("%d ", v) | |
} | |
} | |
fmt.Println(outputStr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment