Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
736 B
2
Indexable
Never
#include <iostream>
#include <vector>

std::vector<int> findZeroIndices(const std::vector<int>& sequence) {
    std::vector<int> zeroIndices;
    for (int i = 0; i < sequence.size(); i++) {
        if (sequence[i] == 0) {
            zeroIndices.push_back(i);
        }
    }
    return zeroIndices;
}

int main() {
    std::vector<int> sequence = {1, 0, 2, 0, 3, 4, 0, 5};  // Пример целочисленной последовательности
    std::vector<int> zeroIndices = findZeroIndices(sequence);
  
    std::cout << "Номера нулевых элементов: ";
    for (int i = 0; i < zeroIndices.size(); i++) {
        std::cout << zeroIndices[i] << " ";
    }
    std::cout << std::endl;
  
    return 0;
}
Leave a Comment