Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
algo de avance
#include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> typedef struct { char mail[321]; char domain[256]; }users; typedef struct { char dominio[256]; unsigned short cantidad; }domains; // -----------------Prototypes---------------------- void findDomain ( char *, char *); int compareDomains( const void *, const void * ); void lowerCase( char *); void registroDominio( const users *, domains *, int); // ---------------Main Program----------------------- int main(void) { users typeDomain[10000]; domains arrayDominios[10000]; int i = 0; int total; //unsigned short sum; // --------------------------Input---------------------- while ( i < 10000) { scanf("%320s", typeDomain[i].mail); if ( strcmp(typeDomain[i].mail, "FIN") == 0) break; i++; } // -----------------------Process----------------------- total = i; for (i = 0 ; i < total ; i++) findDomain(typeDomain[i].mail, typeDomain[i].domain); for (i = 0 ; i < total ; i++) lowerCase(typeDomain[i].domain); qsort(typeDomain, total, sizeof(users), compareDomains); for (i = 0 ; i < total ; i++) printf("%s\n", typeDomain[i].domain); printf("\n\n"); registroDominio( typeDomain, arrayDominios, total); for (i = 0 ; i < total ; i++) printf("%s : %hu\n", arrayDominios[i].dominio, arrayDominios[i].cantidad ); return 0; } void registroDominio( const users *type, domains *array, int total) { short i, j; unsigned short suma; for ( i = 0 ; i < total - 1; i++) { strcpy(array[i].dominio, type[i].domain); suma = 1; for ( j = i + 1; j < total ; j++) { if ( strcmp(array[i].dominio, type[j].domain ) != 0 ) break; else suma ++; } array[i].cantidad = suma; i += (j - i - 1); } } /* -------------------------Procedimiento findDomain------------------------------- * Propósito: encontrar el dominio de un correo electrónico. Ejemplo: * pedro@hotmail.com, el dominio es: hotmail.com * */ void findDomain ( char *mail, char *domain) { char *pointer; pointer = mail; pointer = strchr(mail, '@'); strcpy(domain, pointer + 1); } int compareDomains( const void *pivot, const void *element ) { users *ptrPivot = (users *) pivot; users *ptrElement = (users *) element; return strcmp( ( ptrPivot -> domain ), ( ptrElement -> domain ) ); } void lowerCase( char *domain) { while ( *domain != '\0') { if ( isupper( *domain ) ) *domain = tolower(*domain); domain ++; } }
run
|
edit
|
history
|
help
0
problemapi3
150108_RecursividadFibonacci
Text to ASCII (top)
Test 4
150116_OrdenMatriz
PtStrCpy
tst2.c
RSA Algo
la wea afortunada
Stub Program for Problem 3 HW 2