Exemplo n.º 1
0
Wt::WString TopicWidget::reindent(const Wt::WString& text)
{
  std::vector<std::string> lines;
  std::string s = text.toUTF8();
  boost::split(lines, s, boost::is_any_of("\n"));

  std::string result;
  int indent = -1;
  int newlines = 0;
  for (unsigned i = 0; i < lines.size(); ++i) {
    const std::string& line = lines[i];

    if (line.empty()) {
      ++newlines;
    } else {
      if (indent == -1) {
        indent = countSpaces(line);
      } else {
        for (int j = 0; j < newlines; ++j)
          result += '\n';
      }

      newlines = 0;

      if (!result.empty())
        result += '\n';

      result += skipSpaces(line, indent);
    }
  }
  return Wt::WString::fromUTF8(result);
}
Exemplo n.º 2
0
int main()
{
    int proc = 0, spaces = 0;

    srand((unsigned) time(NULL));

    for (int i = 0; i < RUNS; i++)
    {
        spawn();
        kill();
        proc += countProc();
        spaces += countSpaces();
    }

    printf("Média em %d execuções:\n\n", RUNS);
    printf("Buracos:   %f\n", (double) spaces / (double) RUNS);
    printf("Processos: %f\n", (double) proc /  (double) RUNS);

    return 0;
}