Home>

Please write your question in detail here.
I'm sorry if i am new to the site and find something unsightly.
12345 results without changing the function int data [], int len, int x, int y and without using the for statement
I would like to call it 12435, but I would like to ask for your help.
The changes are in the code below the function int data [], int len, int x, int y.
I kindly thank you.

Error message
Corresponding source code

void swap (int data [], int len, int x, int y);

int main (void)
{
int arr [5] = {1, 2, 3, 4, 5};
int length = sizeof (arr)/sizeof (int);
for (int i = 0;i {
printf ("% d", arr [i]);
}
puts ("");
swap (arr, length, 2, 3);
for (int i = 0;i<5;i ++)
{
printf ("% d", arr [i]);
}
puts ("");
return 0;
}
void swap (int data [], int len, int x, int y)
{
int i = 1;
int temp;
for (i = 0;i {
if (i == x)
{
temp = data [x];
data [x] = data [y];
data [y] = temp;
}
}
}

What I tried

Please describe here what you have tried for the problem.

Supplementary information (FW/tool version, etc.)

Please provide more detailed information here.

c++