Home > Back-end >  Wrong output m began, n also not, c and d, and f are right, for bosses
Wrong output m began, n also not, c and d, and f are right, for bosses

Time:05-24

#include
#include
Int main ()
{
Int max10 (int a [10]);
Int min10 (int a [10]);
Int a, [10].
Int I, Max, min, d, c, f, m;
Float n;
Printf (" please enter the number 10: ");
For (I=0; i<10; I++)
The scanf (" % d ", & amp; A [I]);
D=(a [0] + a + [1] [2] a + a + a [3] [4] + [5] a + a + [6] [7] [8] a + a + a [9]);
Printf (" \ n d=% d ", d);
Max=max10 (a);
Min=min10 (a);
C=Max;
F=min;
M=(c, f);
Printf (" \ n m=% d ", c);

Printf (" \ n c=% d ", c);
Printf (" \ n f=% d ", f);
Printf (" Max=% d \ n ", Max).
Printf (" min=% d \ n ", min);
N=(d) - c - f/8;
Printf (" n=% d \ n ", n);
return 0;
}

Int max10 (int a [10])
{int max2 (int a, int b);
Int m;
M=max2 (a [0], a [1]).
M=max2 (m, a, [2]).
M=max2 (m, a, [3]).
M=max2 (m, a, [4]).
M=max2 (m, a, [5]).
M=max2 (m, a, [6]).
M=max2 (m, a, [7]).
M=max2 (m, a, [8]).
M=max2 (m, a, [9]).
Return (m);
}

Int max2 (int a, int b)
{if (a>=b)
return a;
The else
Return b;
}


Int min10 (int a [10])
{int min2 (int a, int b);
Int m;
M=min2 (a [0], a [1]).
M=min2 (m, a, [2]).
M=min2 (m, a, [3]).
M=min2 (m, a, [4]).
M=min2 (m, a, [5]).
M=min2 (m, a, [6]).
M=min2 (m, a, [7]).
M=min2 (m, a, [8]).
M=min2 (m, a, [9]).
Return (m);
}

Int min2 (int a, int b)
{if (a<=b)
return a;
The else
Return b;
}

CodePudding user response:

Line 20, "printf (" \ n m=% d", c);" And you really want to output m, or output c? Should be changed to "printf (" \ n m=% d", m);"
Line 27, "printf (" n=% d \ n", n);" With integer format "% d" output floating-point number? That, of course, will not output the correct results, should be changed to "printf (" % n=f \ n", n);"
Line 26, if you want to get the decimal, so should be changed to "n=(d) - c - f/8.0;" .
  • Related