Ejemplo n.º 1
0
int			func_key_up(t_edit_line *line)
{
  freeString(line->output_string);
  if (modular_history(0, NULL)->prev == NULL)
    {
      line->output_string = formString(modular_history(0, NULL)->cmd);
      modular_history(1, modular_history(0, NULL)->prev);
    }
  else
    {
      modular_history(1, modular_history(0, NULL)->prev);
      line->output_string = formString(modular_history(0, NULL)->cmd);
    }
  return (0);
}
Ejemplo n.º 2
0
/**
 * Get input=hidden stuffs for submit
 * @param code  Problem code
 * @return Hidden params in pairs
 */
vector < pair < string, string > >CCJudger::getSubmitHiddenParams(string code)
{
	prepareCurl();
	curl_easy_setopt(curl, CURLOPT_URL,
			 ((string) "http://www.codechef.com/submit/" +
			  code).c_str());
	performCurl();

	string html = loadAllFromFile(tmpfilename);
	string form;
	// login form
	if (!RE2::PartialMatch
	    (html, "(?s)(<form.*?node-form.*?</form>)", &form)) {
		throw Exception("Failed to get hidden params.");
	}
	string key, value;
	vector < pair < string, string > >result;
	// get all hidden params
	re2::StringPiece formString(form);
	while (RE2::FindAndConsume(&formString,
				   "(?s)<input type=\"hidden\".*?name=\"(.*?)\".*?value=\"(.*?)\"",
				   &key, &value)) {
		result.push_back(make_pair(key, value));
	}
	return result;
}
Ejemplo n.º 3
0
const char* simpleXMLparser::getPath()
{
  std::list<XMLlevel> errCopy=originalXMLpathList;// Copy;
  XMLlevel tmpLevel;
  tmpS=xmlFileName;
  
  while ( errCopy.size() > 0 )
    {
      tmpLevel=errCopy.front();
      errCopy.pop_front();
      tmpS += "->";
      tmpS += tmpLevel.XMLtagName;

      if ( tmpLevel.XMLtagNumber > 1 )
	{
	  tmpS += '(';
	  tmpS += formString(tmpLevel.XMLtagNumber);
	  tmpS += ')';
	}
   }

  if ( currAtrName != "NULL" )
    {
      tmpS += "(attribute=\"";
      tmpS += currAtrName;
      tmpS += "\")";
    }
  
  return tmpS.c_str();
}
Ejemplo n.º 4
0
int			func_key_down(t_edit_line *line)
{
  if (modular_history(0, NULL) != NULL)
    {
      freeString(line->output_string);
            if (modular_history(0, NULL)->next == NULL)
	{
	  line->output_string = formString(modular_history(0, NULL)->cmd);
	  modular_history(1, modular_history(0, NULL)->next);
	}
      else
	{
	  modular_history(1, modular_history(0, NULL)->next);
	  line->output_string = formString(modular_history(0, NULL)->cmd);
	}
    }
  return (0);
}
Ejemplo n.º 5
0
int main()
{	
	int t,k,i;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&k);
		//printf("%s\n",formString(k));
		int *str=formString(k);
		for(i=0;i!='\0';i++)
			printf("%c",*(str+i));
		printf("\n");
	}
	return 0;
}
Ejemplo n.º 6
0
/**
 * Get input=hidden stuffs for login
 * @return Hidden params in string
 */
string CCJudger::getLoginHiddenParams()
{
	prepareCurl();
	curl_easy_setopt(curl, CURLOPT_URL, "http://www.codechef.com/");
	performCurl();

	string html = loadAllFromFile(tmpfilename);
	string form;
	// login form
	if (!RE2::PartialMatch(html, "(?s)(<form.*?user-login-form.*?</form>)",
			       &form)) {
		throw Exception("Failed to get hidden params.");
	}
	string key, value, result = "";
	// get all hidden params
	re2::StringPiece formString(form);
	while (RE2::FindAndConsume(&formString,
				   "(?s)<input type=\"hidden\".*?name=\"(.*?)\".*?value=\"(.*?)\"",
				   &key, &value)) {
		result += escapeURL(key) + "=" + escapeURL(value) + "&";
	}
	return result;
}
Ejemplo n.º 7
0
int main()
{
    FILE *fin = fopen("contact.in", "r");
    FILE *fout = fopen("contact.out", "w");
    int i, j, begin, end, top, record[200001], count, res[13][4096];
    fscanf(fin, "%d %d %d", &begin, &end, &top);
    
    char buffer[1024];
    count = 0;
    while (fscanf(fin, "%s", buffer) > 0) {
        for (i = 0; i < strlen(buffer); i++)
            record[count++] = buffer[i] - '0';
    }
    
    for (i = 0; i < count; i++) {
        for (j = begin; j <= end; j++) {
            if (i + j > count)
                break;
            int temp = formNumber(record+i, j);
            res[j][temp]++;
        }
    }
    
    struct mark contact[5000];
    count = 0;
    for (i = begin; i <= end; i++) {
        for (j = 0; j < 4096; j++) {
            if (res[i][j] != 0) {
                contact[count].length = i;
                contact[count].value = j;
                contact[count++].count = res[i][j];
            }
        }
    }
    
    sortInsertion(contact, count);
    
    int next, num;
    i = j = 0;
    next = 1;
    while (i < top && j < count) {
        if (next) {
            fprintf(fout, "%d\n", contact[j].count);
            next = 0;
            num = 0;
        }
        char output[13];
        formString(contact[j].length, contact[j].value, output);
        fprintf(fout, "%s", output);
        num++;
        if (contact[j+1].count != contact[j].count) {
            i++;
            next = 1;
            fprintf(fout, "\n");
        }else {
            if (num == 6) {
                fprintf(fout, "\n");
                num = 0;
            }else 
                fprintf(fout, " ");
        }
        j++;
    }
    
    fclose(fin);
    fclose(fout);
}
Ejemplo n.º 8
0
Archivo: roman.c Proyecto: AbiWord/wv
char *
decimalToRoman (long decimal, char *roman)
{
    char *r = roman;
    memset (roman, 0, 81);
    r = roman;
    if (decimal > LARGEST || decimal < 1)
      {
	  *r = '\0';
	  wvError (("roman broke\n"));
	  return roman;
      }
    if (decimal >= Z)
	decimal -= formString (&r, Z, 'Z', '\0');
    if (decimal >= Z - Y)
	decimal -= formString (&r, Z - Y, 'Y', 'Z');
    while (decimal >= Y)
	decimal -= formString (&r, Y, 'Y', '\0');
    if (decimal >= Y - W)
	decimal -= formString (&r, Y - W, 'W', 'Y');
    if (decimal >= N)
	decimal -= formString (&r, N, 'N', '\0');
    if (decimal >= N - W)
	decimal -= formString (&r, N - W, 'W', 'N');
    while (decimal >= W)
	decimal -= formString (&r, W, 'W', '\0');
    if (decimal >= W - U)
	decimal -= formString (&r, W - U, 'U', 'W');
    if (decimal >= B)
	decimal -= formString (&r, B, 'B', '\0');
    if (decimal >= B - U)
	decimal -= formString (&r, B - U, 'U', 'B');
    while (decimal >= U)
	decimal -= formString (&r, U, 'U', '\0');
    if (decimal >= U - S)
	decimal -= formString (&r, U - S, 'S', 'U');
    if (decimal >= T)
	decimal -= formString (&r, T, 'T', '\0');
    if (decimal >= T - S)
	decimal -= formString (&r, T - S, 'S', 'T');
    while (decimal >= S)
	decimal -= formString (&r, S, 'S', '\0');
    if (decimal >= S - Q)
	decimal -= formString (&r, S - Q, 'Q', 'S');
    if (decimal >= R)
	decimal -= formString (&r, R, 'R', '\0');
    if (decimal >= R - Q)
	decimal -= formString (&r, R - Q, 'Q', 'R');
    while (decimal >= Q)
	decimal -= formString (&r, Q, 'Q', '\0');
    if (decimal >= Q - M)
	decimal -= formString (&r, Q - M, 'M', 'Q');
    if (decimal >= P)
	decimal -= formString (&r, P, 'P', '\0');
    if (decimal >= P - M)
	decimal -= formString (&r, P - M, 'M', 'P');
    while (decimal >= M)
	decimal -= formString (&r, M, 'M', '\0');
    if (decimal >= M - C)
	decimal -= formString (&r, M - C, 'C', 'M');
    if (decimal >= D)
	decimal -= formString (&r, D, 'D', '\0');
    if (decimal >= D - C)
	decimal -= formString (&r, D - C, 'C', 'D');
    while (decimal >= C)
	decimal -= formString (&r, C, 'C', '\0');
    if (decimal >= C - X)
	decimal -= formString (&r, C - X, 'X', 'C');
    if (decimal >= L)
	decimal -= formString (&r, L, 'L', '\0');
    if (decimal >= L - X)
	decimal -= formString (&r, L - X, 'X', 'L');
    while (decimal >= X)
	decimal -= formString (&r, X, 'X', '\0');
    switch ((int) decimal)
      {
      case 9:
	  *r++ = 'I';
	  *r++ = 'X';
	  break;
      case 8:
	  *r++ = 'V';
	  *r++ = 'I';
	  *r++ = 'I';
	  *r++ = 'I';
	  break;
      case 7:
	  *r++ = 'V';
	  *r++ = 'I';
	  *r++ = 'I';
	  break;
      case 6:
	  *r++ = 'V';
	  *r++ = 'I';
	  break;
      case 4:
	  *r++ = 'I';
      case 5:
	  *r++ = 'V';
	  break;
      case 3:
	  *r++ = 'I';
      case 2:
	  *r++ = 'I';
      case 1:
	  *r++ = 'I';
	  break;
      }
    return roman;
}