Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PREGUNTA 2 EXAMEN
int Compara(const void *A,const void *B) { unsigned long long *ptrA=(unsigned long long *)A; unsigned long long *ptrB=(unsigned long long *)B; if (*ptrA>*ptrB) return 1;else return -1; } bool EsNum(char *frase) { for (int i=0; frase[i]!='\0'; i++) { if(isdigit(frase[i])){}else return false; } return true; } void FiltrarPolidivisibles (FILE *entrada, FILE **salida) { unsigned long long *vectorPoli=NULL; char Aux[100]; int N=0, lala=0; unsigned long long auxiliar=0; bool esverdad=false; while(fscanf(entrada, "%s", Aux)!=EOF) { if (EsNum(Aux)==true) { lala=strlen(Aux); int a=0, nana=0; unsigned long long resultado=0, final=0; char Ex[100]; nana=lala; for (a=0; a < lala; a++) { Ex[a]=Aux[a]-48; resultado=Ex[a]; for (int j=0; j < nana-1; j++) { resultado=resultado*10; } nana--; final=resultado+final; } nana=lala; auxiliar=final; while (lala!=0) { if((final%lala)==0) { esverdad=true; final/=10; lala--; } else { esverdad=false; break;} } } if ((esverdad==true)&&(EsNum(Aux)==true)) { vectorPoli=realloc(vectorPoli,sizeof(unsigned long long)*(N+1)); vectorPoli[N]=auxiliar; N++; } } qsort(vectorPoli,N,sizeof(unsigned long long),Compara); for (int i=0;i<N;i++) { fprintf(*salida,"%llu\n",vectorPoli[i]); } if (N==0) { fprintf(*salida,"NO SE ENCONTRARON NUMEROS ENTEROS, POSITIVOS Y POLIDIVISIBLES"); } }
run
|
edit
|
history
|
help
0
example of scanf and basic integer manipulation
A_141125_MenorMayor2
ele709 lab 3.2
Class #2, data types
arrows
shapes and such
fgets and basic string manipulation
20171103_factorial
array poi
stringify