Advertisement
ahmad_zizo

Untitled

Dec 25th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. void query()
  2. {
  3. int i,j,k,l;
  4. char swap_[20];
  5. for(i=0; i<counter; i++)
  6. {
  7. lowercase(person[i].fname);
  8. lowercase(person[i].lname);
  9. }
  10. for (i=0 ; i < counter; i++)
  11. {
  12. for (j=0; j < counter-1; j++)
  13. {
  14. if (strcmp(person[j].lname,person[j+1].lname)>0)
  15. {
  16. strcpy(swap_,person[j].lname);
  17. strcpy(person[j].lname,person[j+1].lname);
  18. strcpy(person[j+1].lname,swap_);
  19.  
  20. strcpy(swap_,person[j].fname);
  21. strcpy(person[j].fname,person[j+1].fname);
  22. strcpy(person[j+1].fname,swap_);
  23.  
  24. strcpy(swap_,person[j].address);
  25. strcpy(person[j].address,person[j+1].address);
  26. strcpy(person[j+1].address,swap_);
  27.  
  28. strcpy(swap_,person[j].city);
  29. strcpy(person[j].city,person[j+1].city);
  30. strcpy(person[j+1].city,swap_);
  31.  
  32. strcpy(swap_,person[j].number);
  33. strcpy(person[j].number,person[j+1].number);
  34. strcpy(person[j+1].number,swap_);
  35. }
  36. else if(strcmp(person[j].lname,person[j+1].lname)==0)
  37. {
  38. if (strcmp(person[j].fname,person[j+1].fname)>0)
  39. {
  40. strcpy(swap_,person[j].lname);
  41. strcpy(person[j].lname,person[j+1].lname);
  42. strcpy(person[j+1].lname,swap_);
  43.  
  44. strcpy(swap_,person[j].fname);
  45. strcpy(person[j].fname,person[j+1].fname);
  46. strcpy(person[j+1].fname,swap_);
  47.  
  48. strcpy(swap_,person[j].address);
  49. strcpy(person[j].address,person[j+1].address);
  50. strcpy(person[j+1].address,swap_);
  51.  
  52. strcpy(swap_,person[j].city);
  53. strcpy(person[j].city,person[j+1].city);
  54. strcpy(person[j+1].city,swap_);
  55.  
  56. strcpy(swap_,person[j].number);
  57. strcpy(person[j].number,person[j+1].number);
  58. strcpy(person[j+1].number,swap_);
  59. }
  60. else if(strcmp(person[j].fname,person[j+1].fname)==0)
  61. {
  62. if(strcmp(person[j].number,person[j+1].number)>0)
  63. {
  64. strcpy(swap_,person[j].lname);
  65. strcpy(person[j].lname,person[j+1].lname);
  66. strcpy(person[j+1].lname,swap_);
  67.  
  68. strcpy(swap_,person[j].fname);
  69. strcpy(person[j].fname,person[j+1].fname);
  70. strcpy(person[j+1].fname,swap_);
  71.  
  72. strcpy(swap_,person[j].address);
  73. strcpy(person[j].address,person[j+1].address);
  74. strcpy(person[j+1].address,swap_);
  75.  
  76. strcpy(swap_,person[j].city);
  77. strcpy(person[j].city,person[j+1].city);
  78. strcpy(person[j+1].city,swap_);
  79.  
  80. strcpy(swap_,person[j].number);
  81. strcpy(person[j].number,person[j+1].number);
  82. strcpy(person[j+1].number,swap_);
  83. }
  84. }
  85. }
  86. else
  87. continue;
  88. }
  89. }
  90. system("cls");
  91. for (i=0 ; i <counter; i++)
  92. 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);
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement