Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- struct employed{
- char nama[21],gender[21],divisi[21];
- bool kosong=true,pensiun=false;
- };
- int main()
- {
- struct employed arr[101];
- int a;scanf("%d",&a);
- int count=0;
- for(int i=0;i<a;i++){
- int proses;
- scanf("%d",&proses);
- if(proses==1){
- struct employed temp;
- scanf("\n%[^\n]\n",temp.name);
- scanf("%[^\n]\n",temp.gender);
- scanf("%[^\n]\n",temp.divisi);
- bool isUnique = true;
- for(int j=0;j<count;j++){
- if(arr[j].name==temp.name && !arr[j].kosong){
- isUnique=false;
- break;
- }
- }
- if(isUnique){
- bool isFull=true;
- for(int j=0;j<count;j++){
- if(arr[j].kosong){
- arr[j].name=temp.name;
- arr[j].gender=temp.gender;
- arr[j].divisi=temp.divisi;
- arr[j].kosong=false;
- isFull=false;
- break;
- }
- }
- if(isFull){
- arr[count].name=temp.name;
- arr[count].gender=temp.gender;
- arr[count].divisi=temp.divisi;
- arr[count].kosong=false;
- count++;
- }
- }
- }if(proses==2){
- int c;
- int d;
- scanf("%d %d",&c,&d);
- struct employed temp;
- temp.nama=arr[c].nama;
- temp.gender=arr[c].gender;
- temp.divisi=arr[c].divisi;
- arr[c].nama=arr[d].nama;
- arr[c].gender=arr[d].gender;
- arr[c].divisi=arr[d].divisi;
- arr[d].nama=temp.nama;
- arr[d].gender=temp.gender;
- arr[d].divisi=temp.divisi;
- }if(proses==3){
- int e;
- scanf("%d",&e);
- arr[e].kosong=true;
- }if(proses==4){
- int f;
- scanf("%d",&f);
- arr[f].pensiun=true;
- }
- }
- for(int i=0;i<count;i++){
- if(!arr[i].kosong && !arr[i].pensiun){
- printf("%s\n",arr[i].name);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement