Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #include<stdio.h>
  2. struct employed{
  3. char nama[21],gender[21],divisi[21];
  4. bool kosong=true,pensiun=false;
  5. };
  6.  
  7. int main()
  8. {
  9. struct employed arr[101];
  10. int a;scanf("%d",&a);
  11. int count=0;
  12. for(int i=0;i<a;i++){
  13. int proses;
  14. scanf("%d",&proses);
  15. if(proses==1){
  16. struct employed temp;
  17. scanf("\n%[^\n]\n",temp.name);
  18. scanf("%[^\n]\n",temp.gender);
  19. scanf("%[^\n]\n",temp.divisi);
  20. bool isUnique = true;
  21. for(int j=0;j<count;j++){
  22. if(arr[j].name==temp.name && !arr[j].kosong){
  23. isUnique=false;
  24. break;
  25. }
  26. }
  27. if(isUnique){
  28. bool isFull=true;
  29. for(int j=0;j<count;j++){
  30. if(arr[j].kosong){
  31. arr[j].name=temp.name;
  32. arr[j].gender=temp.gender;
  33. arr[j].divisi=temp.divisi;
  34. arr[j].kosong=false;
  35. isFull=false;
  36. break;
  37. }
  38. }
  39. if(isFull){
  40. arr[count].name=temp.name;
  41. arr[count].gender=temp.gender;
  42. arr[count].divisi=temp.divisi;
  43. arr[count].kosong=false;
  44. count++;
  45. }
  46. }
  47. }if(proses==2){
  48. int c;
  49. int d;
  50. scanf("%d %d",&c,&d);
  51. struct employed temp;
  52. temp.nama=arr[c].nama;
  53. temp.gender=arr[c].gender;
  54. temp.divisi=arr[c].divisi;
  55. arr[c].nama=arr[d].nama;
  56. arr[c].gender=arr[d].gender;
  57. arr[c].divisi=arr[d].divisi;
  58. arr[d].nama=temp.nama;
  59. arr[d].gender=temp.gender;
  60. arr[d].divisi=temp.divisi;
  61. }if(proses==3){
  62. int e;
  63. scanf("%d",&e);
  64. arr[e].kosong=true;
  65. }if(proses==4){
  66. int f;
  67. scanf("%d",&f);
  68. arr[f].pensiun=true;
  69. }
  70. }
  71. for(int i=0;i<count;i++){
  72. if(!arr[i].kosong && !arr[i].pensiun){
  73. printf("%s\n",arr[i].name);
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement