Home > Back-end >  O great god with small white C pointer, program shows no problem, but couldn't run the results
O great god with small white C pointer, program shows no problem, but couldn't run the results

Time:09-18

#include
Void junzhi (int a [], int n, int x, int * y)
{
Int I=0, sum=0, t, z=0;
for(i=0; I<=9; I++)
{the scanf (" % d ", & amp; A [I]);
Sum=sum + a [I]; }
T=1.0 * sum/n;
for(i=0; I<=9; I++)
{the scanf (" % d ", & amp; A [I]);
If (a [I] Z++; }
* x=t;
* y=z;

}
Int main ()
{
Int a [10], I;
Int jun, di;
Printf (" please enter the grade: ");
for(i=0; I<=9; I++)
The scanf (" % d ", & amp; A [I]);
Junzhi (a, 10, & amp; Jun, & amp; Di);
Printf (" % d % d \ n ", jun, di);
Return 0;
}

CodePudding user response:

The scanf save don't need to take the address into the array, the array name is the address of the array

CodePudding user response:

Do you want to count is average and below average? I am also a beginner, not necessarily to, may have a few questions: 1) your function prototype has no return value; 2) in the function prototype is called directly array, should not require the scanf; 3) sure is not a floating-point variable? According to your meaning, I wrote a try, you probably are as follows:
# include & lt; stdio.h>

Double junzhi (double [], int);
Int count (double [], double);

Int main ()
{
Double a [10], jun;
Int di;
Printf (" please enter the result: \ n ");
for(int i=0; I<10; I++)
Lf the scanf (" % ", & amp; A [I]);
Jun=junzhi (a, 10);
Di=count (a, jun);
Printf (" mean is % lf, below average number is % d. \ n ", jun, di);
Return 0;
}

Double junzhi (double a [], int n)
{
Double ret_val;
Double sum=0.0;
for(int i=0; IThe sum +=a [I];
Ret_val=sum/n.
Return ret_val;
}

Int count (double [], a double t)
{
Int ret_val=0;
for(int i=0; IIf (a [I] Ret_val + +;
Return ret_val;
}

If there is any deficiency, please correct me more communication

CodePudding user response:

More than by the way, this type of evaluation, personal feel I use pointer effect is not very good, I have been trapped in the pointer circle before, here in the array pointer still need to use more useful,
  • Related