The code number of all purpose is for not less than num
The following code
# include & lt; stdio.h>
Int main ()
{
Int n=0, I;
Double b [12]={5,0.3, 0.2, 1,0.9, 3,7,15,10,13,0.1, 2}, a, [n].
Double num.
Lf the scanf (" % ", & amp; Num);
for(i=0; i<12. I++)
{
If (b [I] & gt; Num=)
{
[I] a [n++]=b;
}
Printf (" becomes the hapless num % lf \ n ", num);
}
for(i=0; iPrintf (" % 1 f ", a [I]);
return 0;
}
The last if type in 0.5 the result is
The hapless num into 0.500000
The hapless num into 0.500000
The hapless num into 0.500000
The hapless num into 1.000000
The hapless num into 1.000000
The hapless num into 1.000000
The hapless num into 1.000000
The hapless num into 1.000000
The hapless num into 1.000000
The hapless num into 1.000000
The hapless num into 1.000000
The hapless num into 1.000000
5.0 1.0 3.0 7.0 15.0 10.0 13.0 2.0
CodePudding user response:
Changing a [n] to [12] aCodePudding user response:
Array a definition is too small, when the code number more than filling a element array definition, will cover and modify the neighboring num values.CodePudding user response:
A is the length of the array must be defined in advance the C language does not support the variable array length,CodePudding user response:
N=0A [n]
What the hell is?
CodePudding user response:
School haven't modify the textbooks? Undefined strange happens,,,