Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const char* buff[] = {
- "00001",
- "10000",
- "01000",
- "11001",
- "00100",
- "10101",
- "01101",
- "11100",
- "00010",
- "10011",
- "01011",
- "11010",
- "00111",
- "10110",
- "01110",
- "11111"
- };
- enum{_0,_2,_3,_4,_5,_6,_7,_8,_9,_colon,_start,_less,_equal,_greather,_end};
- void main(int argc,char** argv)
- {
- using namespace std;
- vector<string> stk;
- char helper[1024];
- ifstream file("file.csv", ios::binary | ios::in);
- if(!file) return;
- while(!file.eof()){
- file.read(helper, sizeof(helper));
- char* ch = NULL, *h = NULL;
- strtok(helper,";");
- while(1){
- ch = strtok(helper,";");
- if(ch != NULL) h = ch;
- }
- try{ if(h) stk.push_back(ch); else throw h; }
- catch(char* ch)
- {
- cout << "This string is invalid " << ch;
- return;
- }
- }
- file.close();
- if(stk.empty()) return;
- for(vector<string>::iterator i = stk.begin();i != stk.end();i++)
- {
- string out;
- if(i->compare(0,strlen(buff[_start]),buff[_start])) i->reserve();
- try{
- if(i->compare(0,strlen(buff[_start]),buff[_start])) throw *i;
- string msg;
- for(int j=0;j < i->length();j+=5)
- {
- for(int k=_0;k<_end;k++){
- if(strncmp(i->c_str(),buff[k],j))
- {
- if(!strcmp(buff[k],"00001")) msg += "0";
- else if(!strcmp(buff[k],"10000")) msg += "1";
- else if(!strcmp(buff[k],"01000")) msg += "2";
- else if(!strcmp(buff[k],"11001")) msg += "3";
- else if(!strcmp(buff[k],"00100")) msg += "4";
- else if(!strcmp(buff[k],"10101")) msg += "5";
- else if(!strcmp(buff[k],"01101")) msg += "6";
- else if(!strcmp(buff[k],"11100")) msg += "7";
- else if(!strcmp(buff[k],"00010")) msg += "8";
- else if(!strcmp(buff[k],"10011")) msg += "9";
- else if(!strcmp(buff[k],"01011")) msg += ":";
- else if(!strcmp(buff[k],"11010")) msg += "start;";
- else if(!strcmp(buff[k],"00111")) msg += "<";
- else if(!strcmp(buff[k],"10110")) msg += "=";
- else if(!strcmp(buff[k],"01110")) msg += ">";
- else if(!strcmp(buff[k],"11111")) msg += "end;";
- }
- }
- //e.t.c.
- }
- }
- catch(string str)
- {
- cout << "This string is invalid \"" << str.c_str() << "\"!";
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment