Exemplo n.º 1
0
void main()
{
	string strWord,strKey;int i;MSVS msvsDictionary;
	while(cin>>strWord)
	{
		if(strWord.compare("XXXXXX")==0)break;
		strKey=strWord;sort(strKey.begin(),strKey.end());
		if(msvsDictionary.find(strKey)==msvsDictionary.end())
		{
			VS vsList;vsList.push_back(strWord);
			msvsDictionary.insert(MSVS::value_type(strKey,vsList));
		}
		else msvsDictionary[strKey].push_back(strWord);
	}
	while(cin>>strKey)
	{
		if(strKey.compare("XXXXXX")==0)break;
		sort(strKey.begin(),strKey.end());
		if(msvsDictionary.find(strKey)==msvsDictionary.end())cout<<"NOT A VALID WORD"<<endl;
		else
		{
			sort(msvsDictionary[strKey].begin(),msvsDictionary[strKey].end());
			for(i=0;i<msvsDictionary[strKey].size();i++)
				cout<<msvsDictionary[strKey][i]<<endl;
		}
		cout<<"******"<<endl;
	}
}
Exemplo n.º 2
0
string UDFind(VS code){
  int i, j, n = code.size(); string t; Code c;
  set<string> s;               /* Mark tails already seen */
  priority_queue<Code> tails;  /* Keep track of current tails */

  sort(code.begin(), code.end(), cmpSS);
  s.clear();
  for(i = 0; i < n; i++) for(j = i+1; j < n; j++){
    if(code[i] == code[j]) return code[i];
    CHECK(code[i], code[j]);
    CHECK(code[j], code[i]);
  }
  s.clear();
  while(!tails.empty()){
    Code top = tails.top(); tails.pop();
    if(s.count(top.b)) continue;
    s.insert(top.b);
    for(j = 0; j < n; j++){
      if(top.b == code[j]) return top.a+top.b;
      CHECK2(top.b, code[j]);
      CHECK2(code[j], top.b);
    }
  }
  return "";
}
Exemplo n.º 3
0
VS calc( VS s ) {
    Set S;
    for ( VS::iterator it_i = s.begin(); it_i != s.end(); ++ it_i ) {
        string a = *it_i;
        string b = rotate(a);
        cout << a << ", " << b << endl;
        if ( ! is_valid(a) ) {
            if ( is_valid(b) ) {
                S.insert(b);
            }
        } else if ( ! is_valid(b) ) {
            if ( is_valid(a) ) {
                S.insert(a);
            }
        } else {
            if ( S.count(a) )
                S.insert(b);
            else if ( S.count(b) )
                S.insert(a);
            else
                S.insert(min(a, b));
        }
    }
    if ( S.size() != s.size() )
        return VS();
    VS res(S.begin(), S.end());
    return res;
}
Exemplo n.º 4
0
VS parse(string& s) {
	VS v;
	for (int i = s.FN(' '); i < s.length(); i = s.FN(' ', i)) {
		char c = s[i];
		if (is_num(c)) {
			int j = s.FN(NUMS, i);
			if (j == string::npos) {
				v.PB(s.substr(i));
				break;
			}
			v.PB(s.substr(i, j - i));
			i = j;
		}
		else if (is_func(c)) {
			int j = s.FN(FUNS, i);
			v.PB(s.substr(i, j - i));
			i = j;
		}
		else {
			v.PB(s.substr(i, 1));
			i += 1;
		}
	}

	return v;
}
Exemplo n.º 5
0
VS replyVector() {
    VS ret;
    return ret;
    ret.push_back("titi");
    ret.push_back("tutu");
    return ret;
}
int main()
{
    char str[100];
    while(scanf("%s",str))
    {
        int len=strlen(str);
        int ar[100];
        for( int i=0; i<len; i++ ) ar[i]=i;
        VS v;
        string st;
        sort(ar,ar+len);
        do
        {
            for( int i=0; i<len; i++ ) st+=str[ar[i]];
            v.PB(st);
            st.clear();
        }
        while(next_permutation(ar,ar+len));
        for( int i=0; i<v.size()/len; i++ )
        {
            for( int j=i; j<v.size(); j+=7 )
                cout<<v[j]<<endl;
        }
        v.clear();
        printf("\n");
    }
    return 0;
}
Exemplo n.º 7
0
int main() {
	int m, n;
	int i, j, k;
	int max_subfile, max_file;
	string s, x;
	//freopen("f:\\in.txt", "r", stdin);
	while (cin >> s) {
		flist.clear();
		for (i=3; s[i]; ++i) {
			if (s[i] == '\\') flist.push_back(s.substr(0, i));
		}
		n = flist.size();
		for (i=0; i!=n; ++i) {
			if (fc.find(flist[i]) == fc.end()) {
				for (j=0; j!=i; ++j) {
					if (subfile.find(flist[j]) == subfile.end()) subfile.insert(make_pair(flist[j], 1));
					else ++subfile[flist[j]];
				}
				fc.insert(flist[i]);
			}
			if (file.find(flist[i]) == file.end()) file.insert(make_pair(flist[i], 1));
			else ++file[flist[i]];
		}
	}
	max_subfile = 0, max_file = 0;
	for (MSII it=subfile.begin(); it!=subfile.end(); ++it) max_subfile = max(max_subfile, it->second);
	for (MSII it=file.begin(); it!=file.end(); ++it) max_file = max(max_file, it->second);
	printf("%d %d\n", max_subfile, max_file);
	return 0;
}
Exemplo n.º 8
0
void Mesh::addQuad(float width, float height) {
  int indexOffset = positions.size();
  float x = width / 2.0f;
  float y = height / 2.0f;

  VVec4 quad;
  // C++11      { glm::vec3(-x, -y, 0), glm::vec3(x, -y, 0), glm::vec3(x, y, 0), glm::vec3(-x, y, 0),  });
  quad.push_back(glm::vec4(-x, -y, 0, 1));
  quad.push_back(glm::vec4(x, -y, 0, 1));
  quad.push_back(glm::vec4(x, y, 0, 1));
  quad.push_back(glm::vec4(-x, y, 0, 1));

  // Positions are transformed
  add_all_transformed(model.top(), positions, quad);
  if (normals.size()) {
    // normals are transformed with only the rotation, not the translation
    model.push().untranslate();
    add_all_transformed(model.top(), normals, quad);
    model.pop();
  }

  // indices are copied and incremented
  VS quadIndices;
  // C++11 VS( { 0, 1, 2, 0, 2, 3 } );
  quadIndices.push_back(0);
  quadIndices.push_back(1);
  quadIndices.push_back(2);
  quadIndices.push_back(0);
  quadIndices.push_back(2);
  quadIndices.push_back(3);
  add_all_incremented(indexOffset, indices, quadIndices);

  fillColors();
  fillNormals();
}
Exemplo n.º 9
0
 VS convert( string s ) {
     VS res;
     ISS iss(s);
     string word;
     while ( iss >> word )
         res.push_back(word);
     return res;
 }
Exemplo n.º 10
0
void play(MSI& rank, VS& toks) {
	SS oprs;
	SD nums;
	string out = "";
	char str[100];

	cout << "# from infix to postfix!!!" << endl;
	
	for (VS::iterator i = toks.begin(); i != toks.end(); i++) {
		string tok = *i;
		
		cout << "There is a " << tok << ": ";

		if (is_num(tok)) {
			cout << "push to output" << endl;
			sprintf(str, "%.6lf ", stod(tok));
			out += str;
			nums.push(stod(tok));
		}
		else if (tok == ",") {
			cout << "flush the stack until '('" << endl;
			while (oprs.top() != "(")
				calc(oprs, nums, out);
		}
		else if (tok == ")") {
			cout << "flush the stack until '(' and check if there's a func" << endl;
			while (oprs.top() != "(")
				calc(oprs, nums, out);
			oprs.pop();
			if (!oprs.empty() && is_func(oprs.top()))
				calc(oprs, nums, out);
		}
		else {
			cout << "push to stack" << endl;
			if ( is_unary(tok) && (i == toks.begin() || rank[*(i - 1)] > 0) )
				oprs.push("u" + tok);
			else { 
				while (!is_func(tok) && tok != "(" && !oprs.empty() && rank[oprs.top()] <= rank[tok]) {
					cout << "\t*** stack.top() has higher precedence" << endl;
					calc(oprs, nums, out);
				}
				oprs.push(tok);
			}
		}

		cout << "\tcurrent output: " << out << endl
			 << "\tcurrent  stack: " << oprs << endl;
	}

	while (!oprs.empty())
		calc(oprs, nums, out);

	cout << "There is nothing left, so flush the stack to output" << endl
		 << "\tcurrent output: " << out << endl
		 << "#transformation completed!!!" << endl
		 << "Postfix Exp: " << out << endl
		 << "RESULT: " << nums.top() << endl << endl;
}
Exemplo n.º 11
0
string convert( VS list ) {
    OSS oss;
    for ( VS::iterator it_i = list.begin(); it_i != list.end(); ++ it_i ) {
        oss << *it_i;
        if ( it_i + 1 != list.end() )
            oss << " ";
    }
    return oss.str();
}
Exemplo n.º 12
0
VS parse(string s)
{
  string a;
  VS wyn;
  REP(i,(int)s.size())
    if (s[i]!=' ') a+=s[i];
    else if (!a.empty()) { wyn.PB(a); a=""; }
  if (!a.empty()) wyn.PB(a);
  return wyn;
}
Exemplo n.º 13
0
ostream& operator<<(ostream& out, const SS& s) {
	VS v;
	SS ss = s;
	while (!ss.empty()) {
		v.PB(ss.top());
		ss.pop();
	}
	for (int i = v.size() - 1; i >= 0; i--)
		out << v[i] << ' ';
	return out;
}
inline VS split(string s,char* tok) {
    VS vs;
    char *pch;
    char *q= (char*)s.c_str();
    pch=strtok(q," ");
    while(pch !=NULL) {
        vs.pb(string(pch));
        pch=strtok(NULL,tok);
    }
    return vs;
}
Exemplo n.º 15
0
MSM replyMap2() {
    MSM ret;
    VS v;

    return ret;
    v.push_back("titi");
    v.push_back("tutu");

    ret["titi"] = v;
    ret["tutu"] = v;
    return ret;
}
Exemplo n.º 16
0
VS split( string s, string c )
{
  VS ret;
  for( int i=0, n; i <= s.length(); i=n+1 ){

    n = s.find_first_of( c, i );
    if( n == string::npos ) n = s.length();
    string tmp = s.substr( i, n-i );
    ret.push_back(tmp);
  }
  return ret;
}
Exemplo n.º 17
0
int main(){
  int i, n; char buff[MAXL]; VS code;

  while(scanf("%d", &n) == 1){
    code.clear();
    for(i = 0; i < n; i++){
      scanf(" %s", buff);
      code.push_back(buff);
    }
    printf("[%s]\n", UDFind(code).c_str());
  }
  return 0;
}
Exemplo n.º 18
0
 VS splt(std::string s, char c = ',') {
     VS all;
     int p = 0, np;
     while (np = (int)s.find(c, p), np >= 0) {
         if (np != p)
             all.push_back(s.substr(p, np - p));
         else
             all.push_back("");
         
         p = np + 1;
     }
     if (p < s.size())
         all.push_back(s.substr(p));
     return all;
 }
Exemplo n.º 19
0
 VS print(VVI & m) {
     VS M;
     for (int i = 0; i < (int)m.size(); i++) {
         M.push_back("");
         for (int j = 0; j < (int)m[i].size(); j++) {
             ostringstream os;
             os << m[i][j];
             if (j == 0) M[i] += os.str();
             else M[i] += (" " + os.str()); 
         }
     }
     //for (int i = 0; i < (int)M.size(); i++)
         //cout << M[i] << endl;
     return M;
 }
int main(int argc, char *argv[])
{
    libpipe::ctc::Pipeline pipeline;

    pipeline = generatePipeline();
    pipeline.run();

    typedef std::vector<std::string> VS;
    VS trace;
    trace = pipeline.getTrace();
    for (VS::const_iterator i = trace.begin(); i != trace.end(); ++i) {
        std::cout << *i << '\n';
    }

    return EXIT_SUCCESS;
}
Exemplo n.º 21
0
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

        #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        #endif
        VS v;vector<ll> cal;
        int n,m;
        cin>>n>>m;
        rep(i,n)
        {
                string s;
                cin>>s;
                v.pb(s);
        }
Exemplo n.º 22
0
 void filterDataSet(VS &data, const int scenario, const bool includeClass) {
     VI indices;
     if (scenario == 2) {
         VI sc3 = {11, 13, 19, 20, 21, 22, 23, 24, 25, 26};
         indices.insert(indices.begin(), sc3.begin(), sc3.end());
     }
     
     if (scenario >= 1) {
         VI sc2 = {2, 3, 4, 5, 6, 7, 8, 9, 10};
         indices.insert(indices.begin(), sc2.begin(), sc2.end());
     }
     
     VI sc1 = {1, 12, 14, 15, 16, 17, 18};
     indices.insert(indices.begin(), sc1.begin(), sc1.end());
     
     for (int i = 0; i < data.size(); i++) {
         string line = data[i];
         VS values = splt(line);
         string newLine;
         for (int j = 0; j < indices.size(); j++) {
             newLine.append(values[indices[j] - 1]);
             if (j < indices.size() - 1) {
                 newLine.append(",");
             }
         }
         if (includeClass) {
             newLine.append(",");
             newLine.append(values[iqCol]);
         }
         
         // store new data
         data[i] = newLine;
     }
 }
Exemplo n.º 23
0
	rep(i,sz(res)){
		stringstream ss;
		ss<<res[i];
		string s;
		ss>>s;
		r.pb(s);
	}
Exemplo n.º 24
0
VS SplitNotNull(const string& ss, const string& c)
{
	string s = ss + c;
	VS result;
	string tec = "";
	for (int i = 0; i < (int)s.length(); i++)
	{
		if (c.find(s[i]) != string::npos)
		{
			if ((int)tec.length() > 0) result.push_back(tec);
			tec = "";
		}
		else tec += s[i];
	}

	return result;
}
Exemplo n.º 25
0
    friend std::ostream& operator<< (std::ostream& stream, LogEntry &p) {
      stream << "func=" << p.funcName << ", ";

      VS para = p.params;
      stream << "argc=" << para.size() << ", ";
      stream << "args=[";
      for(unsigned j = 0; j < para.size() - 1; j++)
        stream << para[j] << ",";
      stream << para[para.size() - 1] << "], ";
#if GEN_DETAIL
      stream << p.getVal("S=[") << ", ";
      stream << p.getVal("E=[") << ", ";
      stream << p.getVal("D=[") << ", ";
#endif
      stream << p.getVal("R=[") << ", ";
      return stream;
    }
Exemplo n.º 26
0
vector <string> token( string str,string deli )
{
    char * cstr, *p,*deli_c;
    deli_c = new char [deli.size()+1];
    cstr = new char [str.size()+1];
    strcpy(deli_c,deli.c_str());
    strcpy (cstr, str.c_str());
    VS vec;
    p=strtok(cstr,deli_c);
    while(p!=NULL)
    {
        vec.push_back( string(p));
        p=strtok(NULL,deli_c);
    }
    delete[] cstr;
    return vec;
}
Exemplo n.º 27
0
void putstring (string name, VS setid, VS setclass) {
	cout << "<" << name;

	if (setid.size() != 0) {
		cout << " id=\"" << setid[0];
		for (int i = 1; i < setid.size(); i++)
			cout << " " << setid[i];
		cout << "\"";
	}

	if (setclass.size() != 0) {
		cout << " class=\"" << setclass[0];
		for (int i = 1; i < setclass.size(); i++)
			cout << " " << setclass[i];
		cout << "\"";
	}

	cout << ">";
}
Exemplo n.º 28
0
// TODO: make this func more generic ?
string LogEntry::_getKey(const string &line) {

  stringstream s;

  s << funcName << "(";
  for (VS::iterator i = params.begin(), ie = params.end(); i != ie; i++) {
    string p = *i;

    // should not compare any pointer / array type
    if (p.find("0x") == string::npos && p.find("{") == string::npos)
      s << p;
    else
      s << "--"; // this is a field that is not used in the comparison
    if (i + 1 != ie)
      s << ",";
  }
  s << ")";

  return s.str();
}
Exemplo n.º 29
0
 VVI parse(VS M) {
     VVI m;
     for (int i = 0; i < (int)M.size(); i++) {
         m.push_back(VI());
         istringstream is(M[i]);
         int n;
         while (is >> n) {
             m[i].push_back(n);
         }
     }
     return m;
 }
Exemplo n.º 30
0
 static bool update( VS& v ) {
   int n = v.size();
   if ( n <= 1 ) {
     return false;
   }
   if ( n == 2 ) {
     if ( check(v[0], v[1]) ) {
       VS nv;
       nv.push_back(v[0] + v[1]);
       v = nv;
       return true;
     }
     return false;
   }
   string tmp = "";
   for ( auto i = 0; i + 1 < n; ++ i ) {
     tmp += v[i];
     if ( check(tmp, v[i + 1]) ) {
       VS nv;
       nv.push_back(tmp);
       for ( int j = i + 1; j < n; ++ j ) {
         nv.push_back(v[j]);
       }
       v = nv;
       return true;
     }
   }
   return false;
 }