[form] input
[] output form
[the] sample input hypothesis score. The data in TXT for:
60, 90, 80, 70[sample output] result. The data in TXT for: 75.00 90 60
Procedure is as follows: # include
#include
Int main ()
{
The FILE * fp, * fg;
Int a, [4].
Int I, s=0;
Int m, n;
Float c;
If ((fp=fopen (" c: \ \ score. TXT ", "r"))==NULL)
{
Printf (" the File open error! \n");
exit(0);
}
for(i=0; i<4. I++)
{
The fscanf (fp, "% d", & amp; A [I]);
S +=a, [I].
}
C=s/4.0;
M=a, [0]. N=a, [0].
for(i=0; i<4. I++)
{
If (mM=a, [I].
If (n> A [I])
N=a, [I].
}
If ((fg=fopen (" c: \ \ result. TXT ", "w"))==NULL)
{
Printf (" the File open error! \n");
exit(0);
}
Fprintf (fg, "% 2 f % d % d", c, m, n);
Printf (" % 2 f % d % d ", c, m, n);
The fclose (fp);
The fclose (fg);
return 0;
}
Ask why its output to the screen, nothing wrong?
CodePudding user response:
Three values should be outputCodePudding user response:
# include & lt; stdio.h>
#include
Int main ()
{
The FILE * fp, * fg;
Int a, [4].
Int I, s=0;
Int m, n;
Float c;
If ((fp=fopen (" c: \ \ score. TXT ", "r"))==NULL)
{
Printf (" the File open error! \n");
exit(0);
}
for(i=0; i<4. I++)
{
The fscanf (fp, "% d", & amp; A [I]);
S +=a, [I].
}
C=s/4.0;
M=a, [0]. N=a, [0].
//for (I=0; i<4. I++)
for(i=1; i<4. I++)
{
If (mM=a, [I].
If (n> A [I])
N=a, [I].
}
If ((fg=fopen (" c: \ \ result. TXT ", "w"))==NULL)
{
Printf (" the File open error! \n");
exit(0);
}
Fprintf (fg, "% 2 f % d % d \ n", c, m, n);
Printf (" % 2 f % d % d \ n ", c, m, n);
The fclose (fp);
The fclose (fg);
return 0;
}
For your reference ~
Code not found what problem
CodePudding user response:
Results the number of unknown; So in the for loop i<4 does not conform to the questionCodePudding user response:
Thank you,