Home > Back-end >  C for help
C for help

Time:09-25

CodePudding user response:

It is not difficult, is a loop through

Is not a random number? 1000 rand () %

CodePudding user response:

For your reference
 
#include
#include
#include
# define N 1000
using namespace std;

A void setarr (int *)
{
Srand ((int) time (NULL));
int i;
for (i=0; i{
A [I]=rand () % 1000;
}
}

A void sortarr (int *)
{
Int I, Max, min, sum=0;
Float avge=0;
Min=a, [0].
Max=a [N - 1);
for (i=0; i{
The sum +=a [I];
If (Max & lt; A [I])
max=a[i];
If (min & gt; A [I])
Min=a, [I].
}
Avge=sum * 1.0/N;

Cout & lt; <"Maximum value in the array is:" & lt; Cout & lt; <"The minimum value in the array is:" & lt; Cout & lt; <"The average of the array is:" & lt; }

Int main ()
{
Int a [N]={0};
Setarr (a);
Sortarr (a);

return 0;
}

CodePudding user response:

refer to the second floor CHXCHXKKK response:

for reference
 
#include
#include
#include
# define N 1000
using namespace std;

A void setarr (int *)
{
Srand ((int) time (NULL));
int i;
for (i=0; i{
A [I]=rand () % 1000;
}
}

A void sortarr (int *)
{
Int I, Max, min, sum=0;
Float avge=0;
Min=a, [0].
Max=a [N - 1);
for (i=0; i{
The sum +=a [I];
If (Max & lt; A [I])
max=a[i];
If (min & gt; A [I])
Min=a, [I].
}
Avge=sum * 1.0/N;

Cout & lt; <"Maximum value in the array is:" & lt; Cout & lt; <"The minimum value in the array is:" & lt; Cout & lt; <"The average of the array is:" & lt; }

Int main ()
{
Int a [N]={0};
Setarr (a);
Sortarr (a);

return 0;
}

Thank you, see see

CodePudding user response:

The
reference 1/f, arfi response:
it is not difficult, is a cycle traversal

Is not a random number? The rand () % 1000

Thanks, it is a random number is not too familiar with

CodePudding user response:

The
refer to the original poster weixin_45476057 response:


reference weixin_45476057 reply: 3/f
Quote: refer to the second floor CHXCHXKKK response:

for reference
 
#include
#include
#include
# define N 1000
using namespace std;

A void setarr (int *)
{
Srand ((int) time (NULL));
int i;
for (i=0; i{
A [I]=rand () % 1000;
}
}

A void sortarr (int *)
{
Int I, Max, min, sum=0;
Float avge=0;
Min=a, [0].
Max=a [N - 1);
for (i=0; i{
The sum +=a [I];
If (Max & lt; A [I])
max=a[i];
If (min & gt; A [I])
Min=a, [I].
}
Avge=sum * 1.0/N;

Cout & lt; <"Maximum value in the array is:" & lt; Cout & lt; <"The minimum value in the array is:" & lt; Cout & lt; <"The average of the array is:" & lt; }

Int main ()
{
Int a [N]={0};
Setarr (a);
Sortarr (a);

return 0;
}

Thank you, understand understand

Suggest you use c + + random number of engine
  • Related