Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <chrono>
- using namespace std;
- //Создать массив из 10 элементов..
- int main() {
- const int size = 10; //константа, хранящая размер массива
- int array[size] = { 0, 1, 0, 0, 4, 0, 6, 7, 0, 9 }; //объявление и инициализация одномерного массива
- int count0 = 0;
- for (int idx = 0; idx < size - count0; idx++) {
- if (array[idx] == 0) {
- count0++;
- for (int j = idx; j < size - count0; j++) { array[j] = array[j + 1]; }
- array[size - count0] = 0;
- idx--;
- }
- }
- for (int idx = 0; idx < size; idx++) {
- cout << "array[" << idx << "] = " << array[idx] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment