Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
A_141124_arrayMaxMin02
//Title of this code #include <stdio.h> #include <stdlib.h> #include <time.h> #define _T 100 int main(void) { long v[_T]; long a, b; long imax, imin; short i; printf("Valor de a ... "); scanf(" %ld", &a); printf("Valor de b ... "); scanf(" %ld", &b); if(a > b) { a ^= b; b ^= a; a ^= b; } printf("\n\n"); for(srand(time(NULL)) , i = 0 ; i < _T ; i++) { v[i] = a + rand() % (b - a + 1); } for(i = 0 ; i < _T ; i++) { if(i % 10 == 0 && i) { printf("\n"); } printf("%5ld", v[i]); } for(imax = imin = 0 , i = 1 ; i < _T ; i++) { if(v[imax] < v[i]) { imax = i; } if(v[imin] > v[i]) { imin = i; } } printf("\n\n\Máximo: %ld\n", imax); printf("Mínimo: %ld\n", imin); return 0; }
run
|
edit
|
history
|
help
0
Prime
C_141113_Primos02
Float data type.c
Warnings
Intro to Arrays with comments
18BCE2182 ASSESS_1 Q1-2
Assignment 7
-Wconversion double -> int
ternar
14th Feb Project v0.3