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
a weird way to print hello, world! hmm...
18BCE2182 MIDTERM PART-B CRITICAL
A_141117_Primo01
18BCE2182 ASSESS_3 Q3
StructSurvey
B_141202_Cadenas01
Official Hello World
Data Types
Threads_posix
PRIMER PROGRAMA CON MALLOC()