Fist of all, let's assume that by "list" you mean "array." Otherwise we would need your list implementation in order to be able to iterate through the elements.
int[] nums; // assume these are the numbers you want to search through
int nums_length; // also assume that we know how many numbers are in nums
int min; // smallest number in nums
int max; // largest number in nums
// special case for an empty list of numbers: set min = max = 0
if(nums_length == 0) {
min = 0;
max = 0;
}else {
// start min and max off as equal to the first number
min = nums[0];
max = nums[0];
// iterate through nums
int i;
for(i = 1; i < nums_length; ++i) {
// update max, if necessary
if( nums[i] > max ) {
max = nums[i];
}
// update min, if necessary
if(nums[i] < min) {
min = nums[i];
}
}
}
// min and max are now properly set (or both equal to 0 if nums is empty)
indicates the number of machined parts.the number id incremented each time m02,m30 m02= program end m30 =
127.
A program can be looped in Python by wrapping the entire program in a for or while loop. If you wish to loop the program a finite amount of times, it can be done like so (x = the amount of times you want it to loop, this can be a number or variable storing a number): for i in range(0,x): [code] If you wish to loop the program infinitely, you can use a simple while loop: while True: [code]
help me now !!
This sounds like a homework assignment, so I will give you some pseudo code instead of straight C code. [code] OPEN FILE FOR READING IF NOT END OF FILE THEN min = READ FILE INPUT max = min ENDIF WHILE NOT END OF FILE x = READ FILE INPUT IF x < min THEN min = x ENDIF IF x > max THEN max = x ENDIF ENDWHILE CLOSE FILE [/code] If you are using C, then you will need to use fopen(), scanf(), fclose() and maybe feof(). If you are using C++ then you can use fstream, must like you would use cin, except that you have to open the stream, check for end of file and close it.
CODE HINTS ( no spoilers)box under umbrella code is on telescopeliving room code is in bathroomold scroll number to letter code use it on the box in the bedroomclick the smallest to largest decimal
This code find s the largest and the smallest number in an array terminated with a zero. It's not exactely a perfect match for the question but I dion't believe in answering question papers. It's always good to let the student do some work. There's enough example here to cut it down to provide an answer to the question. CODE SEGMENT MOV AX,DATA MOV DS,AX ; initialize DS MOV DI, OFFSET ARRAY ; DI points to the array MOV AX, [DI] ; AX contains the first element MOV LARGEST, AX ; initialize largest MOV SMALLEST, AX ; initialize smallest MOV CX,6 ; loop counter Al: MOV AX, [DI] ; get array value CMP AX, SMALLEST ; [DI] = smallest? JGE A2 ; yes : skip MOV SMALLEST, AX ; no : move [DI] to smallest JMP A3 ; as it is smallest, thus no need ; to compare it with the largest . i A2: CMP AX,LARGEST ; [DI] = largest JLE A3 ; yes : skip MOV LARGEST, AX ; no : mov [Dl] to largest A3: ADD DI,2 ; point to next number LOOP A1 ; repeat the loop until CX = 0 MOV AX, 4C00h INT 21h ; halt, return to DOS CODE ENDS DATA SEGMENT ARRAY DW -1, 2000, -4000, 32767, 500, 0 LARGEST DW ? SMALLEST DW ? DATA ENDS END.
smallest = min (one_number, another_number); ...or... smallest = one_number < another_number ? one_number : another_number;
The serial number is a code that unlocks the program.
A statement in your program is part of the code. In a low-level programming language, a statement will map directly to a single CPU instruction. In a high-level programming language, a statement is the smallest element of the language's syntax.
see the program
The smallest number of bases on a DNA strand needed to code for insulin is approximately 154 bases. This sequence would code for the amino acid sequence that makes up the insulin protein.
The rupiah is the currency of IndonesiaThe smallest coin is 50 rupiah, the largest banknote is 100,000 rupiah.The international trading code is IDR.
indicates the number of machined parts.the number id incremented each time m02,m30 m02= program end m30 =
That's commonly called a bug. Even the smallest spelling error in a line of computer code can have a 'cascade' effect over the whole program.
7!
127.