Home > Back-end >  C language like a dream
C language like a dream

Time:12-26

For bosses to see this piece of code which is wrong? Always prompt segmentation fault

CodePudding user response:

Segmentation fault is a cross-border,

Or wild pointer, oh, not a pointer, that this too,

CodePudding user response:

Once said, to avoid mistakes, have to be that we do not over torque,

CodePudding user response:

refer to the second floor forever74 response:
child once said, to avoid mistakes, is that we do not over torque,

Are you a monkey sent to tease than?   , don't put sprout new bosses, help me to look at specific what is wrong? How to change?

CodePudding user response:

Debugging. Look at where the execution time of pop-up error,

CodePudding user response:

reference 4 floor forever74 response:
debugging, see where execution when a pop-up error,

Not debugging

CodePudding user response:

Reference:
 # include "stdio.h" 
# include "math. H"
Int main (int arg c, char * argv [])
{
Int a [100] [10], I, j, N, M, sum=0, STR=0, l, q;

Float [100]={0}, b c [10]={0}, p=0, f, s=0, k;

The scanf (" % d % d ", & amp; N, & amp; M);

for(i=0; ifor(j=0; JThe scanf (" % d ", & amp; A [I] [j]);//input student achievement

for(i=0; i{
Sum=0;
for(j=0; J{
The sum +=a, [I] [j].
}
[I]=b float (sum)/float (M);//average score
Printf (" % 1 f ", [I] b);
}
printf("\n");

for(j=0; J{
STR=0;
for(i=0; i{
//the scanf (" % d ", a [I] [j]);
STR +=a, [I] [j].
}
C [j]=float (STR)/float (N);
Printf (" % 1 f ", c [j]);
}
printf("\n");

K=float (a [0] [0]).
for(i=0; i{
for(j=0; J{
If (a [I] [j] & gt; K)
{
K=float (a [I] [j]);
L=I;
Q=j;
}
}
}
Printf (" % 1 f % d % d ", k, l + 1, q + 1);//printf (" % 1 f % d % d ", k, l, q);
//break;
printf("\n");

for(i=0; i{
S=s + b [I] * 4;
}
F=s/float (N * M);
for(i=0; i{
P=p + pow (b [I] -f, 2);
}
P=p/float (N);
Printf (" % 1 f \ n ", p);

return 0;
}
  • Related