/* File: prob.cpp Author: Sudarshan S. Chawathe Date: 3rd March, 2003 Terms: GPL For the Maryland Programming Contest, 2003. For details, see the file fcomp-desc.tex, or http://www.cs.umd.edu/ fcomp: A simple implementation of front coding Copyright (C) 2003 Sudarshan S. Chawathe This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include // Uncomment the following lines if using APCS classes // #include "apvector.h" // #include "apmatrix.h" // #include "apstack.h" // #include "apqueue.h" #include "apstring.cpp" /* maximum number of chars in a name: */ #define NAMESIZ 500 /* maximum number of names in database: */ #define MAXNAMES 1000 #define min(a,b) (((a)<=(b) ? (a) : (b))) void encode_db(char names[MAXNAMES][NAMESIZ + 2], int num_names); void decode_db(int offsets[MAXNAMES], char names[MAXNAMES][NAMESIZ + 2], int num_entries); void read_names(char names[MAXNAMES][NAMESIZ + 2], int num_names); void read_db(int offsets[MAXNAMES], char names[MAXNAMES][NAMESIZ + 2], int n); //----------------------------------------------------------------------- // main //----------------------------------------------------------------------- int main(int argc, char * argv[]) { char action[3]; cin >> action; if(action[0] == 'e') { char names[MAXNAMES][NAMESIZ + 2]; int num_names; cin >> num_names; assert (num_names < MAXNAMES); read_names(names, num_names); encode_db(names, num_names); } else if(action[0] == 'd') { int offsets[MAXNAMES]; char names[MAXNAMES][NAMESIZ + 2]; int num_entries; cin >> num_entries; assert (num_entries < MAXNAMES); read_db(offsets, names, num_entries); decode_db(offsets, names, num_entries); } else assert(0); return 0; } void read_names(char names[MAXNAMES][NAMESIZ + 2], int num_names) { for(int i = 0; i < num_names; i++) { cin >> names[i]; } } ////////////////// BEGIN your code /////////////////// void read_db(int offsets[MAXNAMES], char suffixes[MAXNAMES][NAMESIZ + 2], int n) { for(int i = 0; i < n; i++) { } } void encode_db(char names[MAXNAMES][NAMESIZ + 2], int num_names) { } void decode_db(int offsets[MAXNAMES], char names[MAXNAMES][NAMESIZ + 2], int num_entries) { } ////////////////// END your code ///////////////////