Home > Back-end >  C ask bosses
C ask bosses

Time:09-23

#include
Int main (void)
{
Int a [10], [10] b, I, j, * p;
for(i=0; I<10; I++)
The scanf (" % d ", & amp; A [I]);
for(i=0; I<10; I++)
{
For (j=0; J<10 - I - 1; J++)
{
If (a [j] & gt; A [m + 1])
* p=a, [j].
The else
* p=a, a + 1 bonus to [j].
}
[I]=b * p;
}
for(i=0; I<10; I++)
Printf (" % d, b [I]);
return 0;
}
Want to input the number 10 from big to small order, why run not bottom go to

CodePudding user response:

* p=a, [j]. P is a wild pointer

CodePudding user response:

Int p; Variable is enough, not a pointer, use the pointer who initialized to you either a or b will change the value of an array

CodePudding user response:

This train of thought you have some problem, if the first value is the biggest, but you always to find it from the first, after selected, you have not ruled out

CodePudding user response:

You can use a bubble sort or selection sort

CodePudding user response:

This line of thinking has a problem, each selected value should be removed before the next cycle, so sort or a fake

CodePudding user response:

 # include & lt; stdio.h> 

Int main (void)
{
Int a [10], [10] b, I, j, * p;

TMP=a, [0].
for(i=0; I<10; I++)
The scanf (" % d ", & amp; A [I]);

for(i=0; I<10; I++)
{
For (j=0; J<10 - I - 1; J++)
{
If (a [j] & gt; A [m + 1])
//* p=a, [j].
P=& amp; A, [j].
The else
//* p=a, a + 1 bonus to [j].
P=& amp; + 1 a [j];
}
[I]=b * p;
}
for(i=0; I<10; I++)
Printf (" % d, b [I]);
return 0;
}

For your reference ~
There is a problem in the code, the minimum value not in b,
  • Related