Ejemplo n.º 1
0
	SS split_textT(const typename SS::value_type& src,
					const typename SS::value_type& list,
					int limit = 0) noexcept
	{
		SS dst;
		bool tab_back = true;
		typename SS::value_type word;
		for(auto ch : src) {
			bool tab = false;
			if(limit <= 0 || static_cast<int>(dst.size()) < (limit - 1)) {
				if(string_strchr(list, ch)) {
					tab = true;
				}
			}
			if(tab_back && !tab && !word.empty()) {
				dst.push_back(word);
				word.clear();
			}
			if(!tab) word += ch;
			tab_back = tab;
		}
		if(!word.empty()) {
			dst.push_back(word);
		}
		return dst;
	}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
void FormSet::OnButtonOkClick()
{
	SS port = TextPort_.GetText();
	if (port.Length() == 0)
	{
		PopMessage(tcc_("请输入端口号"),800);
		TextPort_.SetFocus();
		return;
	}

	df::StringToInteger(port, G::main.listen_port);

	G::main.hide_window = choice_[0].GetCheck();

	TextPSW_.GetText(port);
	if (port.Length() > 0)
	{
		Sha2Password(port);
		G::main.access_psw = std::move(port);
	}
		

	G::WriteMainIni();
	Close();
}
Ejemplo n.º 4
0
void calc(SS& oprs, SD& nums, string& s) {
	string opr = oprs.top(); oprs.pop();
	if (opr[0] == 'u') s += opr[1];
	else s += opr;
	s += ' ';
	
	double b = nums.top(); nums.pop();
	if (opr[0] == 'u' || (is_func(opr) && opr != "pow")) {
			 if (opr == "u+") nums.push(b);
		else if (opr == "u-") nums.push(-b);

		else if (opr == "sin") nums.push(sin(b));
		else if (opr == "cos") nums.push(cos(b));
		else if (opr == "exp") nums.push(exp(b));
		else if (opr == "log") nums.push(log(b));
		else if (opr == "sqrt") nums.push(sqrt(b));
		else if (opr == "fabs") nums.push(fabs(b));
		return;
	}

	double a = nums.top(); nums.pop();
		 if (opr == "*") nums.push(a * b);
	else if (opr == "+") nums.push(a + b);
	else if (opr == "-") nums.push(a - b);
	else if (opr == "pow") nums.push(pow(a, b));
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
0
int PermutationSum::add (int n) 
{
	SS ss;
	ss << n;
	ST st;
	st = ss.str();
	sort(all(st));
	cout << ss.str() << endl;
	int ret = 0;
	
	do {
		ret += atoi(st.c_str());
	} while(next_permutation(all(st)));
	
	return ret;
}
Ejemplo n.º 7
0
int BackgroundPrinter::FindVerticalAxesDistance(wxDC *dc, std::vector<Draw*> draws, const SS& sd) {
	
	int d = 0;

	for (SS::const_iterator ssi = sd.begin(); ssi != sd.end(); ssi++) {
		set<int>::const_iterator si = (*ssi).begin();
		if ((*ssi).end() == si)
			assert(false);

		int di = *si;
		Draw *draw = draws[di];

		double max = draw->GetDrawInfo()->GetMax();
		double min = draw->GetDrawInfo()->GetMin();
		wxString maxs = draw->GetDrawInfo()->GetValueStr(max, _T(""));
		wxString mins = draw->GetDrawInfo()->GetValueStr(min, _T(""));

		wxString unit = draw->GetDrawInfo()->GetUnit();

		int maxext, minext, unitext, texth;
		dc->GetTextExtent(maxs, &maxext, &texth);
		dc->GetTextExtent(mins, &minext, &texth);
		dc->GetTextExtent(unit, &unitext, &texth);

		int msn = 0;
		do {
			int tw, th;
			dc->GetTextExtent(draws[*si]->GetDrawInfo()->GetUnit(), &tw, &th);
			msn = wxMax(msn, tw);
		} while (++si != (*ssi).end());
		

		int ext = wxMax(unitext, wxMax(maxext, minext));
		ext = wxMax(ext, msn) + line_width;

		d = wxMax(d, ext);

	} 

	return d;

}
Ejemplo n.º 8
0
int main() {
  String input;
  char c;

  while(std::cin >> input) {
    Stack s;
    SS ss;    
    
    unsigned int j = 0;
    while(j < input.size() && isprint(c = input[j++])) {
      if(c == '[') {
	unsigned int k = j;
	while(isNormalLetter(c = input[k]))
	  ++k;
	if(k == j)
	  continue;
	input[k] = '\0';
	s.push(String(&input[j]));
	input[k] = c;
	j = k;
      }
      else if(c == ']') {
        // nop
      }
      else {
	ss << c;
      }
    }

    // First print Stack, then SS.
    while(!s.empty()) {
      std::cout << s.top();
      s.pop();
    }
    std::cout << ss.str() << std::endl;
  }
}
Ejemplo n.º 9
0
int main(){
  string s1;
  int t,n,m,i,j;
  ios::sync_with_stdio(0);
  while(cin>>t){
    for(int ncase=1;ncase<=t;++ncase){
      cin>>n>>m;
      myset.clear();
      while(n--){
        cin>>s1;
        add(split(s1));
      }
      cnt=0;
      while(m--){
        cin>>s1;
        solve(split(s1));
      }
      printf("Case #%d: %d\n",ncase,cnt);
    }
  }
}
Ejemplo n.º 10
0
Archivo: t2.cpp Proyecto: rve/conf
template < class T > string converter( T n ){SS x;x << n;return x.str();} 
string convtos (T a)
{
    SS ss;
    ss << a;
    return ss.str();
}
Ejemplo n.º 12
0
void solve(SV v){
  for(int i=0;i<v.size();++i){
    if(!myset.count(v[i]))cnt++;
    myset.insert(v[i]);
  }
}
Ejemplo n.º 13
0
void add(SV v){
  for(int i=0;i<v.size();++i)
    myset.insert(v[i]);
}
Ejemplo n.º 14
0
int teams_template_struct(void) {
  SS<int, 123, 456> V;
  return V.foo();

}
Ejemplo n.º 15
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;
}
Ejemplo n.º 16
0
bool DrawsPrintout::OnPrintPage(int page) {
	if (page != 1)
		return false;
	int sel = 0;
	for (; sel < m_draws_count; ++sel) 
		if (m_draws[sel]->GetSelected())
			break;
	if (sel == m_draws_count)
		return false;
	wxDC *dc = GetDC();
#ifndef MINGW32
	try {
		wxPostScriptDC *psdc = dynamic_cast<wxPostScriptDC*>(dc);
		if (psdc != nullptr)
			psdc->PsPrint(_("\n/ISOLatin1Encoding [\n/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/minus/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef/.notdef/Lslash/lslash/Nacute/nacute/aogonek/Cacute/cacute/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/dotlessi/grave/acute/Oacute/tilde/macron/breve/dotaccent/Eogonek/eogonek/Sacute/sacute/.notdef/hungarumlaut/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron/degree/plusminus/twosuperior/oacute/acute/mu/paragraph/periodcentered/.notdef/Zacute/zacute/.notdef/z/onehalf/threequarters/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/Ograve/Oacute/.notdef/.notdef/.notdef/multiply/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/oacute/.notdef/.notdef/.notdef/divide/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n] def\n"));
	} catch(...) { // tu ew. usuniecie polskich znakow
	}
#endif

	wxFont f;
#ifdef __WXMSW__ 
	f.Create(50, wxSWISS, wxNORMAL, wxNORMAL);
#else
	f.Create(8, wxSWISS, wxNORMAL, wxNORMAL);
#endif

	dc->SetMapMode(wxMM_TEXT);
	dc->SetFont(f);

	int ppiw, ppih;
	GetPPIPrinter(&ppiw, &ppih);
	//to milimiters
	ppiw /= 25;
	ppih /= 25;
	int lorigin = Print::page_setup_dialog_data->GetMarginTopLeft().x * ppiw;
	int torigin = Print::page_setup_dialog_data->GetMarginTopLeft().y * ppih;
	dc->SetDeviceOrigin(lorigin, torigin);

	int tw,th;
	dc->GetTextExtent(_T("Z"), &tw, &th);

	int topmargin, bottommargin, rightmargin;
	topmargin = 0;
	bottommargin = int(1.4 * th) + Print::page_setup_dialog_data->GetMarginBottomRight().y * ppih;
	rightmargin = 10 + Print::page_setup_dialog_data->GetMarginBottomRight().x * ppiw;
	SS cd = ChooseDraws();
	for (SS::iterator i = cd.begin(); i != cd.end(); i++) {
		int tm = (th + line_width) * (i->size() + 1);
		if (tm > topmargin)
			topmargin = tm;
	}
	int w, h, pw, ph;
	dc->GetSize(&w, &h);
	GetPageSizePixels(&pw, &ph);
	dc->SetUserScale((float)w / (float)pw, (float)h / (float)ph);

	BackgroundPrinter bp(0, rightmargin, topmargin, bottommargin);
	bp.SetFont(f);
	bp.SetSize(pw - print_left_margin - lorigin, (ph - print_top_margin - torigin) * 2 / 3);

	int graph_start = bp.PrintBackground(dc, m_draws, cd);
	bp.GetSize(&w, &h);
	GraphPrinter gp(
#ifdef __WXGTK__
			2, 
#else
			10, 
#endif
			graph_start, rightmargin, topmargin, bottommargin);
	gp.SetSize(w, h);
	gp.SetFont(f);

	gp.PrintDraws(dc, m_draws, m_draws_count);	
	PrintShortDrawNames(&gp, dc);
	PrintDrawsInfo(dc, lorigin, torigin, rightmargin, bottommargin);

	return true;
}
Ejemplo n.º 17
0
int BackgroundPrinter::PrintBackground(wxDC *dc, std::vector<Draw*> draws, const SS& sd) {

	dc->SetTextForeground(GetTimeAxisCol());
	dc->SetBrush(wxBrush(GetTimeAxisCol(), wxSOLID));

	int ax_dist = FindVerticalAxesDistance(dc, draws, sd);

	SS::iterator ssi = sd.begin();
	do {
		set<int>::iterator si = (*ssi).begin();
		if ((*ssi).end() == si) 
			assert(false);
		int di = *si;

		m_draw = draws[di];

		m_leftmargin += ax_dist;

		SS::iterator next = ssi;
		next++;
		if (next == sd.end()) {
			int w,h;
			GetSize(&w, &h);
			w = w - m_leftmargin + ax_dist;
			SetSize(w, h);

			DrawBackground(dc);
#ifdef __WXMSW__
			DrawTimeAxis(dc, 48, 24, 15, 7);
#else
			DrawTimeAxis(dc, 8, 4, 6);
#endif
		}

		DrawYAxisVals(dc, tick_len, line_width);
		DrawYAxis(dc, arrow_height, arrow_width, line_width);

		int x = (int)(arrow_width * 1.2) , y = line_width;

		int textw, texth;
		DrawUnit(dc, x, y);
		dc->GetTextExtent(draws[*si]->GetDrawInfo()->GetUnit(), &textw, &texth);

		wxColour pc = dc->GetTextForeground();
		y = m_topmargin;
		for (set<int>::reverse_iterator i = (*ssi).rbegin(); i != (*ssi).rend(); i++) {
			DrawInfo* di = draws[*i]->GetDrawInfo();
			dc->GetTextExtent(di->GetShortName(), &textw, &texth);

			dc->SetTextForeground(di->GetDrawColor());
			dc->DrawText(di->GetShortName(), m_leftmargin - 2 * line_width - textw, y - texth - line_width);
			y -= texth + line_width;

		}
		dc->SetTextForeground(pc);

		++ssi;
		
	} while (ssi != sd.end());

	return m_leftmargin;

}