Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
A_141125_MenorMayor2
//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; short i, j, k; short cM, cm; long imayor, imenor; printf("Valor de a ... "); scanf(" %ld", &a); printf("Valor de b ... "); scanf(" %ld", &b); if(a > b) { a ^= b; b ^= a; a ^= b; } for(srand(time(NULL)) , i = 0 ; i < _T ; i++) { v[i] = a + rand() % (b - a + 1); } printf("\n\n"); for(i = 0 ; i < _T ; i++) { if(i % 10 == 0 && i) { printf("\n"); } printf("%6ld", v[i]); } for(imenor = imayor = 0 , cM = cm = 1 , i = 1 ; i < _T ; i++) { if(v[imayor] == v[i]) { cM++; } else if(v[imayor] < v[i]) { cM = 1; imayor = i; } if(v[imenor] == v[i]) { cm++; } else if(v[imenor] > v[i]) { cm = 1; imenor = i; } } long arrayMayor[cM]; long arrayMenor[cm]; for(i = 0 , j = 0, k = 0 ; i < _T ; i++) { if(v[i] == v[imayor]) arrayMayor[j++] = i; if(v[i] == v[imenor]) arrayMenor[k++] = i; } printf("\n\nMenor: %ld [%ld]", v[imenor], imenor); printf("\nMayor: %ld [%ld]", v[imayor], imayor); printf("\n\nIndices mayor:\n"); for(j = 0 ; j < cM ; j++) { printf("%4ld", arrayMayor[j]); } printf("\n\nIndices menor:\n"); for(k = 0 ; k < cm ; k++) { printf("%4ld", arrayMenor[k]); } return 0; }
run
|
edit
|
history
|
help
0
purple ghost red orange blue skulls
Divisibility :- #simple-math #ad-hoc-1 #basics
QuickSort
Lab 9 v0.9
SAI_1-3.c
WHY_?
a
Dangling
this
Project 3 part 2 Book v0.6