Pham Quỳnh
New member
Which of the following code fragment puts sorted values in an array using beads correctly?
A.
B.
C.
D.
[/i][/i]
A.
Code:
for (int i = 0; i < n; i++)
{
int j;
for (j = 0; j < max; j++);
//max is the maximum value element of given array a[]
a[i] = j;
i}
Code:
for (int i = 0; i < n; i++)
{
int j;
for (j = 0; j < max && beads[i * max + j]; j++);
//max is the maximum value element of given array a[]
a[i] = j;
}
Code:
for (int i = 0; i < n; i++)
{
int j;
for (j = 0; j < beads[i * max + j]; j++);
//max is the maximum value element of given array a[]
a[j] = i;
}
Code:
for (int i = 0; i < n; i++)
{
int j;
for (j = 0; j < max && beads[i * max + j]; j++);
//max is the maximum value element of given array a[]
a[j] = i;
}