I have a problem, if you know how to solve it, please help
I have a task, and I can't complete it, I don't understand what needs to be added so that the subtraction occurs in a cycle, and not once. task: Create a new array of the same length as the source array, where the element in position X is equal to the difference of elements in positions X and X-a of the source array, where a is a number entered by the user. Elements with indexes less than a are copied into the result array. Example: for the array {1,2,7,4,9} with the entered number 2 the result will be {1,2,6,2,2} (ie 1, 2, 7-1, 4-2, 9-7) My attempt: #include <iostream> using namespace std; int main() { setlocale(LC_CTYPE, "ukr"); int a[10] = { 1,2,3,4,5,6,7,8,9,10 }; int c[10] = { 1,2,3,4,5,6,7,8,9,10 }; int b; cout << "enter a number: " << endl; cin >> b; cout <<"initial array: "<< endl; for (int i = 0; i < 10; i++) { if (b == a [i]) { c[i] = a[i - b]; } cout << c[i] << endl; } }