any one command that automatically detects, for example, 10 of which entered the largest numbers .. or what is the smallest? and thus may ausgebn then. so Code: printf ("the smallest number:% i", x) printf ("the largest number:% i", y)
hi, you can save the pay in a dynamic array, then sort. forward then is the largest and the smallest rear, or the reverse, according as. I think it is also name.max? correct me if I am wrong!
If the numbers are stored in an array, they can be sorted with qsort easy. # Include <stdlib.h> void qsort (....);
So that nothing goes wrong, i have a small program added. qsort you still need a comparison function. Code: # Include <stdlib.h> CompareInt int (const void * p_void1, const void * p_void2) ( const int * p_int1 = (const int *) p_void1; const int * p_int2 = (const int *) p_void2; if (* p_int1 <* p_int2) return -1; else if (* p_int1> * p_int2) return 1; else return 0; ) void main () ( ArrayOfInt int [10]; / * Array show * / qsort (ArrayOfInt, 10, sizeof (int), CompareInt); )
store in an array and then sort it is cheese ... if the numbers are entered, you can decide but already, what the largest / smallest number is .... Code: # Include <stdio.h> int main (void) ( int i, max, min; scanf ("% d", & i) max = min = i; while (i! = -1) ( if (i> max) max = i; if : (i <min) min = i; scanf ("% d", & i); ) printf ("Max:% d - Min:% d", max, min); return 0; )
So actually, I had not known .. now I come to your code but not really for mady! for what: scanf ("% d", & i) max = min = i; .... not me of course!? and the while loop I think is not necessary ... Code: # Include <stdio.h> void main (void) ( int i, max, min, a, b, c; printf ("Please enter 3zahlen:"); scanf ("% i% i% i", & a, & b, & c); ( if (i> max) max = i; => which I Tschegg not know why this is, but no sense and what is% d - so d? if : (i <min) min = i; scanf ("% i", & i); ) printf ("Max:% i - min:% i, max, min); ) I would have to do now in my opinion, set, or for the variable i to be taken into account or just pay what the pay compared to improve the transfer eingegbn solln .... how do you das. ..... so i made the variable a, b, c consist and it should be max, and min
If you want to enter only three numbers, which is probably not a problem. In my solution I assumed that you have to Enter as many numbers. Therefore the loop. A statement such as Code: min = max = i; says only that min and max get the value for i. Two's If necessary, a etvl. set new min or max value. But that is only necessary if you want to process multiple inputs. If you actually reads only three values, then the whole thing is much easier. You have to stop only compare a, b and c each other and Sun set the maximum and minimum value ...
no, I have to pay out of 10 (times also could be more) to spend the max and min number Lassner .... Compare what each other is for the special? but your code would not work ...... or rather I do not know how I pay any of - to enter in the code to integrate ....
Then you need ne loop ... As always compare - as you type things and everything is ok .. Hmmm ... I think I have an error. Simply compile times and in the console (Windows users - start right?) And numbers in sequence to enter ....
nö I use console wizard .... why do you always take place ...% d% i? and so I like to go the little Schnall .... I'll give 10 as a pay does happen ... but nothing (if it were somehow logical that one ne max. no. pay to enter the setting you can ... or I can yes, ever the press enter key and the program does not know whether it can finally break the max, min heraussuchn number )....... or one defines the press at a certain button, the program the max, min picks out a number, would it? it would be nice if you one-nothing like me, it could explain a little bit closer but is really nice that you answer is always something
well ... in my Progy the loop continues until you enter -1 as value ... % D is habit ... Try out the matter with -1, and again to check out my solution. Then you check that ...