Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdbool.h>
- typedef struct{
- char tamanho[10000];
- }sexo;
- int cmp (const void *p1, const void *p2){
- sexo *a = (sexo*)p1;
- sexo *b = (sexo*)p2;
- return strcmp(a->tamanho,b->tamanho);
- }
- int main(){
- int i,n,j,count = 0;
- while (scanf("%d", &n)>0){
- sexo v[n], teste;
- for(i = 0 ; i < n ; i++)
- scanf("%s",v[i].tamanho);
- qsort(v,n,sizeof(sexo),cmp);
- teste = v[0];
- for( i = 1; i < n ; i++){
- for( j = 0 ; j < strlen(v[i].tamanho); j++){
- if(teste.tamanho[j] == v[i].tamanho[j])
- count++;
- else{
- teste = v[i];
- break;
- }
- }
- }
- printf("%d\n",count);
- count = 0;
- }
- return 0;
- }
- /*
- 6
- 11112222
- 34566666
- 22223333
- 11113333
- 22221111
- 34566676
- 14 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement