Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C_141126_ArrayRepetidos
//Title of this code #include <stdio.h> #include <stdlib.h> #include <time.h> #define _T 100 int main(void) { long v[_T]; long i, j; long a, b; long todosDistintos; 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(todosDistintos = 1 , i = 0 ; i < _T && todosDistintos ; i++) { for(j = i + 1 ; j < _T && todosDistintos ; j++) { if(v[i] == v[j]) { todosDistintos = 0; } } } if(todosDistintos) printf("\n\nNO HAY REPETIDOS\n"); else printf("\n\nSÍ HAY REPETIDOS (%ld) (%ld)\n", i - 1, j - 1); return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
C_141113_euclides
FahrenheitToCelciusReverse
blue saver go my marshal green
Character testing
18BCE2182 ASSESS_1 Q1-2
xd
1.1 Hello World!
Prgm
Class Friday 1/20 Inauguration Day
ctest
Please log in to post a comment.