Untitled
unknown
plain_text
3 years ago
4.1 kB
6
Indexable
///Liberías*******************************************************************************************************************************
# include <stdio.h>
# include <math.h>
# include <stdlib.h>
# include <string.h>
///Constantes*****************************************************************************************************************************
# define MAX_CHAR 50
# define MAX_PERS 10
///Estructuras****************************************************************************************************************************
typedef struct {
char name_M[MAX_CHAR];
char genderM;
int ageM;
}Christian;
typedef struct {
char name_M[MAX_CHAR];
char genderM;
int ageM;
}Moons;
typedef struct {
char name_DS[MAX_CHAR];
char genderDS;
int ageDS;
}DemonSlayers;
typedef struct {
DemonSlayers demonslayers[MAX_PERS];
Moons moons[MAX_PERS];
Christian christian[MAX_PERS];
int demons;
int humans;
int chris;
}Kimetsu_Characters;
typedef Kimetsu_Characters ufotable;
///Funciones******************************************************************************************************************************
// D|daki|C|wiwi|D|muzan|D|akaza|H|tanjiro|H|mitsuri|H|zenitsu|D|nezuko|C|Christian|C|chis
///MAIN___________________________________________________________________________________________________________________________________
int main(){
ufotable personaje;
personaje.demons = 0;
personaje.humans = 0;
personaje.chris = 0;
char input[100];
int lenght = 0;
int i = 0, j = 0;
printf ("Input: ");
fgets (input, 100, stdin);
input [ strlen( input ) - 1 ] = '\0';
lenght = strlen (input);
printf ("Your INPUT is: %s", input);
printf ("\nYour INPUT has %d characters.\n", lenght);
while ( input[i] != '\0' ) {
if(input[i] == 'D') {
//Es un demonio
personaje.demons++;
i++;
i++;
j = 0;
while (input[i] != '|' && input[i] != '\0') {
personaje.demonslayers[personaje.demons-1].name_DS[j] = input[i];
j++;
i++;
}
personaje.demonslayers[personaje.demons-1].name_DS[j] = '\0';
if(input[i] != '\0') {
i++;
}
} else {
if(input[i] == 'H') {
//Es un humano
personaje.humans++;
i++;
i++;
j = 0;
while (input[i] != '|' && input[i] != '\0') {
personaje.moons[personaje.humans-1].name_M[j] = input[i];
j++;
i++;
}
personaje.moons[personaje.humans-1].name_M[j] = '\0';
if(input[i] != '\0') {
i++;
}
} else {
if(input[i] == 'C') {
//Es christian
personaje.chris++;
i++;
i++;
j = 0;
while (input[i] != '|' && input[i] != '\0') {
personaje.christian[personaje.chris-1].name_M[j] = input[i];
j++;
i++;
}
personaje.christian[personaje.chris-1].name_M[j] = '\0';
if(input[i] != '\0') {
i++;
}
}
}
}
}
printf("Total of demons: %d\n", personaje.demons);
for(i = 0; i < personaje.demons; i++) {
printf("\tDEMON %d: %s\n", i+1, personaje.demonslayers[i].name_DS);
}
printf("Total of humans: %d\n", personaje.humans);
for(i = 0; i < personaje.humans; i++) {
printf("\tHUMAN %d: %s\n", i+1, personaje.moons[i].name_M);
}
printf("Total of christian: %d\n", personaje.chris);
for(i = 0; i < personaje.chris; i++) {
printf("\tCHRISTIAN %d: %s\n", i+1, personaje.christian[i].name_M);
}
return 0;
}
Editor is loading...