Herowaree

Teste

Dec 5th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4. struct lista{
  5. char numero[205];
  6. };
  7.  
  8. int main(){
  9.  
  10. int n;
  11.  
  12. while(scanf("%d", &n) != EOF ){
  13.  
  14. struct lista telefonica[n];
  15.  
  16. int i;
  17. for(i = 0; i < n; i++){
  18. scanf("%s", telefonica[i].numero);
  19. }
  20.  
  21. int subtotal, total = 0, j, tam = strlen(telefonica[0].numero);
  22.  
  23. for(i = 1; i < n; i++){
  24. subtotal = 0;
  25. for(j = 0; j < tam; j++){
  26. if(telefonica[i].numero[j] == telefonica[i - 1].numero[j]){
  27. subtotal = subtotal + 1;
  28. }
  29. }
  30.  
  31. if(subtotal > total){
  32. total = subtotal;
  33. }
  34. }
  35.  
  36. printf("%d\n", total);
  37.  
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment