Pushok

some shit

Mar 5th, 2011
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.16 KB | None | 0 0
  1. const char* buff[] = {
  2.     "00001",
  3.     "10000",
  4.     "01000",
  5.     "11001",
  6.     "00100",
  7.     "10101",
  8.     "01101",
  9.     "11100",
  10.     "00010",
  11.     "10011",
  12.     "01011",
  13.     "11010",
  14.     "00111",
  15.     "10110",
  16.     "01110",
  17.     "11111"
  18. };
  19.  
  20. enum{_0,_2,_3,_4,_5,_6,_7,_8,_9,_colon,_start,_less,_equal,_greather,_end};
  21.  
  22. void main(int argc,char** argv)
  23. {
  24.     using namespace std;
  25.     vector<string> stk;
  26.  
  27.     char helper[1024];
  28.  
  29.     ifstream file("file.csv", ios::binary | ios::in);
  30.     if(!file) return;
  31.  
  32.     while(!file.eof()){
  33.         file.read(helper, sizeof(helper));
  34.         char* ch = NULL, *h = NULL;
  35.         strtok(helper,";");
  36.         while(1){
  37.             ch = strtok(helper,";");
  38.             if(ch != NULL) h = ch;
  39.         }
  40.         try{ if(h) stk.push_back(ch); else throw h; }
  41.         catch(char* ch)
  42.         {
  43.             cout << "This string is invalid " << ch;
  44.             return;
  45.         }
  46.     }
  47.  
  48.     file.close();
  49.  
  50.     if(stk.empty()) return;
  51.  
  52.     for(vector<string>::iterator i = stk.begin();i != stk.end();i++)
  53.     {
  54.         string out;
  55.         if(i->compare(0,strlen(buff[_start]),buff[_start])) i->reserve();
  56.  
  57.         try{
  58.             if(i->compare(0,strlen(buff[_start]),buff[_start])) throw *i;
  59.  
  60.             string msg;
  61.             for(int j=0;j < i->length();j+=5)
  62.             {
  63.                 for(int k=_0;k<_end;k++){
  64.                     if(strncmp(i->c_str(),buff[k],j))
  65.                     {
  66.                         if(!strcmp(buff[k],"00001")) msg += "0";
  67.                         else if(!strcmp(buff[k],"10000")) msg += "1";
  68.                         else if(!strcmp(buff[k],"01000")) msg += "2";
  69.                         else if(!strcmp(buff[k],"11001")) msg += "3";
  70.                         else if(!strcmp(buff[k],"00100")) msg += "4";
  71.                         else if(!strcmp(buff[k],"10101")) msg += "5";
  72.                         else if(!strcmp(buff[k],"01101")) msg += "6";
  73.                         else if(!strcmp(buff[k],"11100")) msg += "7";
  74.                         else if(!strcmp(buff[k],"00010")) msg += "8";
  75.                         else if(!strcmp(buff[k],"10011")) msg += "9";
  76.                         else if(!strcmp(buff[k],"01011")) msg += ":";
  77.                         else if(!strcmp(buff[k],"11010")) msg += "start;";
  78.                         else if(!strcmp(buff[k],"00111")) msg += "<";
  79.                         else if(!strcmp(buff[k],"10110")) msg += "=";
  80.                         else if(!strcmp(buff[k],"01110")) msg += ">";
  81.                         else if(!strcmp(buff[k],"11111")) msg += "end;";
  82.                     }
  83.                 }
  84.                 //e.t.c.
  85.             }
  86.         }
  87.         catch(string str)
  88.         {
  89.             cout << "This string is invalid \"" << str.c_str() << "\"!";
  90.             return;
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment