problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing770类 参考

AcWing 770. 单词替换 更多...

#include <acwing.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

AcWing 770. 单词替换

在文件 acwing.h1241 行定义.

成员函数说明

◆ main()

int acwing::acwing770::main ( istream &  cin,
ostream &  cout 
)
static

在文件 acwing.cpp4000 行定义.

4000 {
4001 auto *str = new char[101];
4002 auto *to_be_replaced = new char[101];
4003 auto *replacement = new char[101];
4004 cin.getline(str, 101);
4005 cin.getline(to_be_replaced, 101);
4006 cin.getline(replacement, 101);
4007 for(const char *word = strtok(str, " "); word != nullptr; word = strtok(nullptr, " ")) {
4008 if(strcmp(word, to_be_replaced) == 0) {
4009 cout.write(replacement, strlen(replacement));
4010 } else {
4011 cout.write(word, strlen(word));
4012 }
4013 cout << " ";
4014 }
4015 delete[] str;
4016 delete[] to_be_replaced;
4017 delete[] replacement;
4018 return 0;
4019 }

被这些函数引用 acwing::TEST().


该类的文档由以下文件生成: