Advertisement
ahmad_zizo

Untitled

Dec 25th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. void print()
  2. {
  3. int i,j,k,l;
  4. phonebook swap_;
  5. for (i=0 ; i < counter; i++)
  6. {
  7. for (j=0; j < counter-1; j++)
  8. {
  9. if (strcmpi(person[j].lname,person[j+1].lname)>0)
  10. {
  11. swap_=person[j];
  12. person[j]=person[j+1];
  13. person[j+1]=swap_;
  14. }
  15. else if(strcmpi(person[j].lname,person[j+1].lname)==0)
  16. {
  17. if (strcmpi(person[j].fname,person[j+1].fname)>0)
  18. {
  19. swap_=person[j];
  20. person[j]=person[j+1];
  21. person[j+1]=swap_;
  22. }
  23. else if(strcmpi(person[j].fname,person[j+1].fname)==0)
  24. {
  25. if(strcmp(person[j].number,person[j+1].number)>0)
  26. {
  27. swap_=person[j];
  28. person[j]=person[j+1];
  29. person[j+1]=swap_;
  30. }
  31. }
  32. }
  33. else
  34. continue;
  35. }
  36. }
  37. system("cls");
  38. for (i=0 ; i <counter; i++)
  39. printf("%d)\nfirst name: %s\nlast name: %s\nAddress: %s\nCity: %s\nNumber: %s\n",i+1,person[i].fname,person[i].lname,person[i].address,person[i].city,person[i].number);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement