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


C++ Printer::print方法代码示例

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


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

示例1: printReversed

void printReversed(const string &line) {
    size_t position = 0;
    Printer p;
    unsigned int number;

    static vector<int> values;

    values.clear();

    while (line[position] != ';') {
        getUnsignedInteger(line, position, number);
        values.push_back(number);
    }

    getUnsignedInteger(line, position, number);

    if (number > values.size() ) {
        number = values.size();
    }

    int start = number - 1;
    while (start < values.size() ) {
        for (int i = start; i > start - (int)number; --i) {
            p.print(values[i]);
        }
        start += number;
    }

    for (int i = start - number + 1; i < values.size(); i++) {
        p.print(values[i]);
    }

    cout << endl;
}
开发者ID:Ation,项目名称:codeeval,代码行数:34,代码来源:main.cpp

示例2: stackPrintAlternate

void stackPrintAlternate(const string &line) {
    int end;
    int start;
    char *data = const_cast<char*>(line.c_str());
    Printer p;

    end = line.length() - 1;

    back(data, start, end);
    p.print(&( data[start] ));

    while (true) {
        end = start - 1;
        back(data, start, end);
        if (start <= 0) {
            break;
        }

        end = start - 1;
        back(data, start, end);
        data[end + 1] = 0;

        if (end < 0) {
            break;
        }
        p.print(&( data[start] ));
    }
	cout << endl;
}
开发者ID:Ation,项目名称:codeeval,代码行数:29,代码来源:main.cpp

示例3: separateContent

void separateContent(const string &line) {
    size_t  start = 0;
    size_t  length = 0;
    size_t  end;

    list<string>    words;
    list<string>    numbers;

    Printer         linePrinter;

    while (start < line.length()) {
        end = start + 1;
        while (end < line.length()) {
            if (line[end] == ',') {
                break;
            }

            end++;
        }

        length = end - start;

        if (line[start] >= '0' && line[start] <= '9') {
            numbers.emplace_back(line, start, length);
        } else {
            words.emplace_back(line, start, length);
        }
        start = end + 1;
    }

    if (!words.empty()) {
        for(auto&& word : words) {
            linePrinter.print(word);
        }

        if (!numbers.empty()) {
            cout << '|';
            linePrinter.reset();
        }
    }

    if (!numbers.empty()) {
        for(auto&& number : numbers) {
            linePrinter.print(number);
        }
    }

    cout << endl;
}
开发者ID:Ation,项目名称:codeeval,代码行数:49,代码来源:main.cpp

示例4: printCash

void printCash(const string &line) {
    size_t position = 0;
    unsigned int price;
    unsigned int amount;

    Printer cashier;

    price = getPrice(line, position);
    amount = getPrice(line, position);

    if (price == amount) {
        cout << "ZERO" << endl;
        return;
    }

    if (price > amount) {
        cout << "ERROR" << endl;
        return;
    }

    amount -= price;

    for (auto i = cash.rbegin(); i != cash.rend() && amount != 0; ++i) {
        while (amount >= i->second) {
            cashier.print(i->first);
            amount -= i->second;
        }
    }

    cout << endl;
}
开发者ID:Ation,项目名称:codeeval,代码行数:31,代码来源:main.cpp

示例5: main

int main(int argc, char* argv[])
{
	Printer* printer = NULL;
	Printer* console_printer = console_printer_create();
	Printer* file_printer = file_printer_create("./log.txt");

	printer = console_printer;
	printer->print(printer, "hello world!\n");
	printer->destroy(printer);

	printer = file_printer;
	printer->print(printer, "hello world!\n");
	printer->destroy(printer);

	return 0;
}
开发者ID:xianjimli,项目名称:misc,代码行数:16,代码来源:c-virtual.c

示例6: main

int main(int argc, char* argv[]){

	// c++11 initializer_list constructor
	Printer obj = {10};
	std::cout << obj() << std::endl;

	obj.print("obj.print");

	// mem_fn 转换
	auto func = std::mem_fn(&Printer::print);

	obj.data = 100;
	func(obj, "mem_fun");

	// bind 绑定
	auto func2 = std::bind(&Printer::print, &obj, _1);
	func2("bind");

	// bind操作符函数绑定
	auto func3 = std::bind(&Printer::operator(), &obj);
	std::cout << "bind operator() " << func3() << std::endl;

	// mem_fn 操作符转换为普通函数
	auto func4 = std::mem_fn(&Printer::operator());
	std::cout << "mem_fun operator() " << func4(obj) << std::endl;

	return 0;
}
开发者ID:emptylau,项目名称:hungry,代码行数:28,代码来源:mem_fn.cpp

示例7: accept

void IncLit::accept(::Printer *v)
{
	if(type_ == VOLATILE)
	{
		Printer *printer = v->output()->printer<Printer>();
		printer->print(vol_window_);
	}
}
开发者ID:grote,项目名称:oclingo,代码行数:8,代码来源:inclit.cpp

示例8: print

    void print() const {
        Printer p;

        for (auto it = m_data.rbegin(); it != m_data.rend(); ++it) {
            p.print(*it);
        }
        cout << endl;
    }
开发者ID:Ation,项目名称:codeeval,代码行数:8,代码来源:main.cpp

示例9: grounded

bool Display::grounded(Grounder *g)
{
    head_->grounded(g);
    Printer *printer = g->output()->printer<Printer>();
    printer->show(show_);
    printer->print(head_.get());
    return true;
}
开发者ID:lilac,项目名称:iASP,代码行数:8,代码来源:display.cpp

示例10: print_backtrace

void print_backtrace(std::size_t frames = 32)
{
    using namespace backward;
    StackTrace stackTrace;
    Printer printer;

    stackTrace.load_here(frames);
    printer.object = true;
    printer.color = true;
    printer.print(stackTrace, stdout);
}
开发者ID:waffle-iron,项目名称:siplasplas,代码行数:11,代码来源:backward-cpp.cpp

示例11: main

int main() {
	std::vector<int> container;

	for (int i = 0; i < 5; ++i) {
		container.push_back(i);
	}

	Printer<Out, Out, Out> printer;

	printer.print(container);

	return 0;
}
开发者ID:gamepattisiere,项目名称:laboratory,代码行数:13,代码来源:Argument.cpp

示例12: set

void Ram::set(vector<bool> adr, vector<bool> wordIn) {
	int address = Util::getInt(adr);
	// Save word
	if (address < RAM_SIZE) {
		for (int i = 0; i < WORD_SIZE; i++) {
			state[address][i] = wordIn[i];
		}
	// Send word to printer
	} else {
		char formatedInt [4];
		sprintf(formatedInt, "%3d", Util::getInt(wordIn));
		string outputLine = Util::getString(wordIn) + " " + formatedInt + "\n";
		printer.print(outputLine);
	}
}
开发者ID:ketralnis,项目名称:comp-cpp,代码行数:15,代码来源:comp.cpp

示例13: printIntersection

void printIntersection(const string &line) {
    size_t first_position;
    size_t second_position;

    size_t delimiter_position;

    Printer printer;

    for (delimiter_position=0; delimiter_position < line.length(); delimiter_position++) {
        if (line[delimiter_position] == ';' ) {
            break;
        }
    }

    first_position = 0;
    second_position = delimiter_position + 1;

    unsigned int first = getUnsignedInteger(line, first_position);
    unsigned int second = getUnsignedInteger(line, second_position);

    while (true) {
        if (first == second) {
            printer.print(first);

            if (first_position >= delimiter_position) {
                break;
            }
            first = getUnsignedInteger(line, first_position);

            if (second_position >= line.length()) {
                break;
            }
            second = getUnsignedInteger(line, second_position);
        } else if ( first < second) {
            if (first_position >= delimiter_position) {
                break;
            }
            first = getUnsignedInteger(line, first_position);
        } else {
            if (second_position >= line.length()) {
                break;
            }
            second = getUnsignedInteger(line, second_position);
        }
    }

    cout << endl;
}
开发者ID:Ation,项目名称:codeeval,代码行数:48,代码来源:main.cpp

示例14: run

void run() {
	if (executionCounter > 0) {
		printer.print("            \n");
	}
	savedRam = ram.state;
	cpu.exec();
	// if 'esc' was pressed then it doesn't wait for keypress at the end
	if (executionCanceled) {
		executionCanceled = false;
	} else {
		getc(stdin);
	}
	ram = Ram();
	ram.state = savedRam;
	cpu = Cpu();
	redrawScreen();
	executionCounter++;
}
开发者ID:ketralnis,项目名称:comp-cpp,代码行数:18,代码来源:comp.cpp

示例15: main

int main(int argc, char * argv[])
{

    int c;
    int option_index = 0;

    string truth_file="";
    string result_file="";
    string gene_file="";
    string output_file="";
    string rule_file="";
    int base_resolution=1;
    int max_diff=20;
    string pseudo_counts="0,0,0,0,0,0";
    int print_num=0;

    static struct option long_options[] = {
        {"truth-file",            required_argument, 0,  't' },
        {"result-file",           required_argument, 0,  'r' },
        {"gene-annotation-file",  required_argument, 0,  'g' },
        {"output-file",           required_argument, 0,  'o' },
        {"subsetting-rule-file",  required_argument, 0,  's' },
        {"base-resolution",       required_argument, 0,  'b' },
        {"max-diff",              required_argument, 0,  'm' },
        {"pseudo-counts",         required_argument, 0,  'p' },
        {"use-number",            no_argument,       0,  'u' },
        {"help",                  no_argument,       0,  'h' },
        {0, 0, 0, 0}
    };

    while(1)
    {
        c = getopt_long(argc, argv, "t:r:g:o:s:b:m:p:uh",
                 long_options, &option_index);
        if (c==-1)
        {
            break;
        }
        switch(c)
        {
            case 'h':
                usage();
                exit(0);
            case 't':
                truth_file=optarg;
                break;
            case 'r':
                result_file=optarg;
                break;
            case 'g':
                gene_file=optarg;
                break;
            case 'o':
                output_file=optarg;
                break;
            case 's':
                rule_file=optarg;
                break;
            case 'b':
                base_resolution=atoi(optarg);
                break;
            case 'm':
                max_diff=atoi(optarg);
                break;
            case 'p':
                pseudo_counts=optarg;
                break;
            case 'u':
                print_num=1;
                break;
            default:
                break;
        }

    }


    if(truth_file.compare("")==0 || result_file.compare("")==0 || gene_file.compare("")==0 || output_file.compare("")==0|| rule_file.compare("")==0)
    {
        usage();
        exit(0);
    }

    pseudo_counts_t pct;
    get_pseudo_counts(pseudo_counts, pct);

    cerr<<"loading gene annotation file..."<<endl;    

    Gene g;
    g.loadGenesFromFile((char*)gene_file.c_str());
    g.setGene();    

    cerr<<"loading result file..."<<endl;

    Bedpe res;
    res.loadFromFile((char *)result_file.c_str());

    cerr<<"removing duplicate results..."<<endl;
    res.uniq();
    
//.........这里部分代码省略.........
开发者ID:brianjohnhaas,项目名称:SMC-RNA-Challenge,代码行数:101,代码来源:main.cpp


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