Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Ahora si?
#include <stdio.h> #include <stdlib.h> #include <time.h> void aleatorio (int *, int); void clean (int *, int*); int main(){ int *vector ; int N = 10 ; vector = (int*)malloc(N*sizeof(int)); if (vector == NULL){ printf("no se pudo reservar espacio en la memorioa"); exit(1); } aleatorio(vector,N); clean(vector,&N); } void aleatorio ( int *vector, int N ){ srand(time(NULL)); for (int i = 0 ; i < N ; i++){ *(vector+i) = rand()%4; if ( i+1 < N ) printf("%d, ",*(vector+i)); else printf("%d.",*(vector+i)); } printf("\n"); } void clean(int *vector, int *N){ int j ; for (int i = 0 ; i < *N ; i++){ j = i +1 ; while(j < *N ){ if (*(vector+i) == *(vector+j)){ for (int k = j ; k+1 < *N ; k++){ *(vector+k) = *(vector+k+1); } *N = *N -1 ; } else{ j++; } } } for (int t = 0 ; t < *N ; t++){ printf("%d, ",*(vector+t)); } printf("\n el nuevo valor de N es de %d.",*N); }
run
|
edit
|
history
|
help
0
C code to compare two texts in form of array of chars ignoring the capitalization
C_141113_Primo01
Exploiting uninitialized variable 2
My C Code
ptr_to_ptr
FunPointBreakfast
24-June-2015
else if
mypro
funciones matrices