#include <stdio.h>
typedef struct program{
int count;
int addr[2000];
char op[2000];
} Program;
void Init(Program *pr);
void Insert(Program *pr, int value_1, char value_2);
void Print(Program *pr);
void Calc(Program *pr);
int main(void) {
Program pr[2];
char op;
int value_1;
char value_2;
int count=0;
int num;
//init
Init(&pr[0]);
Init(&pr[1]);
while(count!=2){
scanf("%c", &op);
//printf("%c", input[0]);
if(op=='D'){
printf("\nDelete");
scanf("%d", &value_1);
printf(": %d\n", value_1);
Insert(&pr[count], value_1, 0);
}else if(op=='I'){
printf("\nInsert");
scanf("%d %c", &value_1, &value_2);
printf(": %d %c\n", value_1, value_2);
Insert(&pr[count], value_1, value_2);
}else if(op=='E'){
printf("\nEnd\n");
count++;
}
//return 0;
}
printf("S: check------------\n");
Print(&pr[0]);
Print(&pr[1]);
printf("E: check------------\n");
//Calc
Calc(&pr[0]);
Calc(&pr[1]);
printf("\nafter calc\n");
printf("S: check------------\n");
Print(&pr[0]);
Print(&pr[1]);
printf("E: check------------\n");
//ans
if(isSame(&pr[0], &pr[1])){
printf("%d", 0);
}else {
printf("%d", 1);
}
printf("\nEnd function");
return 0;
}
int isSame(Program *pr_1. Program *pr_2){
int same = 0;
int count = pr_1->count;
while()
return 0;
}
void Calc(Program *pr){
int count = pr->count;
int temp_addr;
for(int i=0; i<count; i++){
if(pr->op[i]==0){
//D operation
temp_addr = pr->addr[i];
for(int k=0; k<i; k++){
if(pr->addr[k]==temp_addr && pr->op[k]!=0){
pr->count = count-2;
pr->addr[k] = pr->addr[i] = 0;
}
}
for(int k=i+1; k<count; k++){
if(pr->addr[k] >= temp_addr){
pr->addr[k] += 1;
}
}
}else {
//I operation
temp_addr = pr->addr[i];
for(int k=0; k<i; k++){
if(pr->addr[k] >= temp_addr){
pr->addr[k] += 1;
}
}
}
}
}
void Print(Program *pr){
printf("Print program, count: %d\n", pr->count);
for(int i=0; i<pr->count; i++){
printf(" %d ", pr->addr[i]);
}
printf("\n");
for(int i=0; i<pr->count; i++){
printf(" %d ", pr->op[i]);
}
printf("\nEnd show\n");
}
void Insert(Program *pr, int value_1, char value_2){
int count = pr->count;
pr->count = count+1;
pr->addr[count] = value_1;
pr->op[count] = value_2;
}
void Init(Program *pr){
pr->count = 0;
for(int i=0; i<2000; i++){
pr->addr[i] = 0;
}
}