📄 main.c
字号:
#include <stdio.h>#include <stdlib.h>#include "circular_bst.h"#define LINE_LENGTH 64int m;int main(int argc, char** argv){ FILE *fp = NULL; char line[LINE_LENGTH], event; int id, type;// CreateNew_dt(-1,5); /* Check command line arguments */ if( argc < 3 ) { printf("\n Usage: %s <m> <input-file>\n", argv[0]); return(EXIT_FAILURE); } /* Read the m parameter */ m = atoi(argv[1]); /* Open input file */ if( ( fp = fopen(argv[2], "r") ) == NULL ) { printf("\n Could not open file: %s\n", argv[2]); return(EXIT_FAILURE); } /* Read input file line-by-line and handle the events */ while( fgets(line, LINE_LENGTH, fp) != NULL ) { /* Uncomment the line below when in debug mode */ /* printf("\n Event: %s ", line); */ switch(line[0]) { /* Join event */ case 'J': sscanf(line, "%c %d", &event, &id); /* id: the id of the node to be inserted */ Insert_dt(id); /* your code... */ break; /* Leave event */ case 'L': sscanf(line, "%c %d", &event, &id); /* id: the id of the node to be deleted */ Delete_dtfinal(id); /* your code... */ break; /* Insert event */ case 'I': sscanf(line, "%c %d %d", &event, &id, &type); /* id: the id of the file, type: the type of the file to be inserted */ Insert_File(id,type); /* your code... */ break; /* Delete event */ case 'D': sscanf(line, "%c %d", &event, &id); /* id: the id of the file, to be deleted */ Delete_File(id); /* your code... */ break; /* Find event */ case 'F': sscanf(line, "%c %d", &event, &id); /* id: the id of the file, to be searched for */// Find_File(id); /* your code... */ break; /* Print event */ case 'P': sscanf(line, "%c", &event); print_dt(); /* your code... */ break; /* Ignore everything else */ default: /* Uncomment the line below when in debug mode */// printf("\n Ignoring line: %s", line); break; } } return (EXIT_SUCCESS);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -