当前位置: 首页>>代码示例>>C++>>正文


C++ VS::size方法代码示例

本文整理汇总了C++中VS::size方法的典型用法代码示例。如果您正苦于以下问题:C++ VS::size方法的具体用法?C++ VS::size怎么用?C++ VS::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VS的用法示例。


在下文中一共展示了VS::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

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;
}
开发者ID:robinmbstu11,项目名称:UVA,代码行数:28,代码来源:10394_Titans+are+in+Danger.cpp

示例2: filterDataSet

 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;
     }
 }
开发者ID:yaricom,项目名称:childstuntedness5,代码行数:34,代码来源:TestRunner.cpp

示例3: UDFind

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 "";
}
开发者ID:AssaultKoder95,项目名称:codejam,代码行数:25,代码来源:ud_find.cpp

示例4: main

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;
}
开发者ID:delta4d,项目名称:AlgoSolution,代码行数:30,代码来源:C.cpp

示例5: update

 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;
 }
开发者ID:sh19910711,项目名称:codeforces-solutions,代码行数:29,代码来源:main.cpp

示例6: calc

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;
}
开发者ID:sh19910711,项目名称:topcoder-solutions,代码行数:28,代码来源:DateFormat.cpp

示例7:

    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;
    }
开发者ID:HDFGroup,项目名称:Replayer,代码行数:17,代码来源:combine.cpp

示例8: putstring

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 << ">";
}
开发者ID:JeraKrs,项目名称:ACM,代码行数:19,代码来源:hdu4964.cpp

示例9:

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;
}
开发者ID:kevin1kevin1k,项目名称:dsa2015,代码行数:11,代码来源:3_4_2.cpp

示例10: parse

 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;
 }
开发者ID:1code,项目名称:topcoder,代码行数:12,代码来源:MatArith.cpp

示例11: split

 static VS split( const std::string& s ) {
   VS res;
   string rs = s;
   std::reverse(begin(rs), end(rs));
   string tmp;
   for ( auto c : rs ) {
     tmp += c;
     if ( c != '0' ) {
       std::reverse(begin(tmp), end(tmp));
       res.push_back(tmp);
       tmp = "";
     }
   }
   if ( tmp != "" ) {
     std::reverse(begin(tmp), end(tmp));
     res.push_back(tmp);
     tmp = "";
   }
   std::reverse(begin(res), end(res));
   while ( res.size() >= 2 ) {
     bool flag = false;
     if ( res[0].size() == res[1].size() && res[0] < res[1] ) {
       flag = true;
     } else if ( res[0].size() < res[1].size() ) {
       flag = true;
     }
     if ( flag ) {
       // cout << "res = " << res[0] << " / " << res[1] << endl;
       res[0] += res[1];
       res.erase(begin(res) + 1);
     } else {
       break;
     }
   }
   while ( update(res) );
   return res;
 }
开发者ID:sh19910711,项目名称:codeforces-solutions,代码行数:37,代码来源:main.cpp

示例12: generateTestData

            void generateTestData(const int scenario, const int subset) {
                size_t subset_total = dataSamples.size() / subsetsNum;
                int train_start_index = subset * (int)subset_total;
                int test_start_index = train_start_index + subset_total * 0.66;
                int end_index = train_start_index + (int)subset_total;
                if (end_index > dataSamples.size()) {
                    end_index = (int)dataSamples.size();
                }
                
                //
                // prepare train data
                //
                DTrain.clear();
                double mean = 0;
                int countIq = 0;
                for (int i = train_start_index; i < test_start_index; i++) {
                    VS rows = dataSamples[i];
                    for (int r = 0; r < rows.size(); r++) {
                        string line = rows[r];
                        VS values = splt(line);
                        double iq = atof(values[iqCol].c_str());
                        
                        if (scenario > 0) {
                            DTrain.push_back(line);
                        } else if (iq > 0) {
                            // add only line with IQ set for 1 scenario
                            DTrain.push_back(line);
                        }
                        
                        if (iq > 0) {
                            mean += iq;
                            countIq++;
                        }
                    }
                }
//                filterDataSet(DTrain, scenario, true);
                
                //
                // prepare test data
                //
                DTest.clear();
                groundTruth.clear();
                for (int i = test_start_index; i < end_index; i++) {
                    VS rows = dataSamples[i];
                    for (int r = 0; r < rows.size(); r++) {
                        string line = rows[r];
                        VS values = splt(line);
                        double iq = atof(values[iqCol].c_str());
                        if (iq > 0) {
                            groundTruth.push_back(iq);
                            // add only line with IQ set for 1 scenario
                            DTest.push_back(line);
                        } else if (scenario > 0) {
                            DTest.push_back(line);
                        }
                    }
                }
//                filterDataSet(DTest, scenario, false);
                
                //
                // calculate sse0
                //
                mean /= countIq;
                sse0 = 0;
                for (const double &iq : groundTruth) {
                    double e = mean - iq;
                    sse0 += e * e;
                }
            }
开发者ID:yaricom,项目名称:childstuntedness5,代码行数:69,代码来源:TestRunner.cpp

示例13: main

int main() {
	ios_base::sync_with_stdio(false);
	int T;
	cin >> T;
	string s;
	getline(cin, s);
	getline(cin, s);
	while(T--){
		bool f;
		do{
			f = getline(cin, s);
			V.push_back(s);
		}while(s.size() > 0 && f);
//		for(int i=0; i<4; i++){
//			getline(cin, s);
//			V.push_back(s);
//		}
//		
		map<string, int> SS;
		map<string, int> SS1;
		map<int, string> RE;
		VS name(V.size());
		VS party(V.size());
		vector<VS> club(V.size());
		
		int k = 1;
		int c = 0;
		
		for(int i=0; i<V.size(); i++){
			int p1;
			for(p1=0; p1<V[i].size(); p1++){
				if(V[i][p1] == ' ') break;
				name[i] += V[i][p1];
			}
			for(p1 = p1+1; p1 < V[i].size(); p1++){
				if(V[i][p1] == ' ') break;
				party[i] += V[i][p1];
			}
			while(p1 < V[i].size()){
				string temp;
				for(p1 = p1+1; p1 < V[i].size(); p1++){
					if(V[i][p1] == ' ') break;
					temp += V[i][p1];
				}
				if(!SS1.count(temp)){
					SS1[temp] = c;
					RE[c] = temp;
					c++;
				}
				club[i].push_back(temp);
			}
			if(!SS.count(party[i]))
				SS[party[i]] = k++;
		}
		MaxFlowDinic MD( 80000 );
		
		map<string, int>::iterator it;
		for(it = SS.begin(); it != SS.end(); it++){
			MD.add_edge(0, it->second, SS.size()%2==0? SS.size()/2-1:SS.size()/2);
		}
		
		k = SS.size() + 1;
		for(int i=0; i<V.size(); i++, k++){
			int p = SS[party[i]];
			MD.add_edge(p, k, 1);
			for(int j=0; j<club[i].size(); j++){
				MD.add_edge(k, SS1[club[i][j]] + SS.size() + 1 + V.size(), 1);
			}
		}
		
		for(it = SS1.begin(); it != SS1.end(); it++){
			MD.add_edge( (it->second) + SS.size() + 1 + V.size(), 
					SS1.size() + SS.size() + 1 + V.size(), 1);
		}
		
		int res = MD.dinic(0, SS1.size() + SS.size() + 1 + V.size());
		if(res < SS1.size()){
			cout << "Impossible." << endl;
		}else{
			for(int i=0; i<MD.edges.size(); i+=2){
				if(MD.edges[i].v == SS1.size() + SS.size() + 1 + V.size()) continue;
				if(MD.edges[i].u < SS.size() + 1) continue;
				if(MD.edges[i].flow <= 0) continue;
				int u = MD.edges[i].u;
				int v = MD.edges[i].v;
				u -= (SS.size() + 1);
				v -= (SS.size() + 1 + V.size());
				cout << name[u] << " " << RE[v] << endl;
			}
		}
		if(T > 0){
			cout << endl;
		}
	}
    return 0;
}
开发者ID:m4b3l,项目名称:algorithm,代码行数:96,代码来源:10511.cpp

示例14: INOUT

void
LEARN::learn (VS vf)
{
  INFOGO *infop;
  SGFROOT *p;
  for (int v = 0; v < vf.size (); ++v)
    {
      n_zobrist = 0;
      ___.tic ("zobrist");
      p = INOUT ().sgf2tree (vf[v]);

      // 16 种对称方式编码不一样
      for (int k = 0; k < 2; ++k)
        {
          for (int i = 0; i < 8; ++i)
            {
              infop = new INFOGO;
              g_init.swap_id8_q8 (0, i);
              p->fuseki (infop);
              for (int j = 0; j < p->sons.size (); ++j)
                {
                  visit (p->sons[j], infop, &LEARN::insert_zobrist);
                }
              g_init.swap_id8_q8 (0, i);
              infop->delfromroot ();
            }
          g_init.swap_xorand ();
        }
      /*
         // 16 种对称方式下编码都一样
         infop = new INFOGO; 
         p->fuseki(infop); 
         for (int i = 0; i<p->sons.size(); ++i){
         visit(p->sons[i], infop, &LEARN::insert_pemis); 
         infop->delfromroot(); 
         }
       */
      delete p;
      ___.toc ();
  }
  for (int v = 0; v < vf.size (); ++v)
    {
      n_pemis = 0;
      ___.tic ("pemis");
      p = INOUT ().sgf2tree (vf[v]);

      /*
         // 16 种对称方式编码不一样
         for (int k = 0; k<2; ++k){
         for (int i = 0; i<8; ++i) {
         infop = new INFOGO; 
         g_init.swap_id8_q8(0, i); 
         p->fuseki(infop); 
         for (int j = 0; j<p->sons.size(); ++j){
         visit(p->sons[j], infop, &LEARN::insert_zobrist); 
         }
         g_init.swap_id8_q8 (0, i); 
         infop->delfromroot(); 
         }
         g_init.swap_xorand(); 
         }
       */
      // 16 种对称方式下编码都一样
      infop = new INFOGO;
      p->fuseki (infop);
      for (int i = 0; i < p->sons.size (); ++i)
        {
          visit (p->sons[i], infop, &LEARN::insert_pemis);
          infop->delfromroot ();
        }
      delete p;
      ___.toc ();
    }
  INOUT ().save2txt (vf, "encodelib/filenames.txt");
}
开发者ID:shoutgo,项目名称:shoutgo,代码行数:75,代码来源:learn.cpp

示例15: get_maximum_number

 static Int get_maximum_number( const std::string& s ) {
   VS ret = split(s);
   // cout << endl; for ( auto x : ret ) {cout << x << endl; } cout << endl;
   return ret.size();
 }
开发者ID:sh19910711,项目名称:codeforces-solutions,代码行数:5,代码来源:main.cpp


注:本文中的VS::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。