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

AcWing 774. 最长单词 更多...

#include <acwing.h>

静态 Public 成员函数

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

详细描述

AcWing 774. 最长单词

在文件 acwing.h1279 行定义.

成员函数说明

◆ main()

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

在文件 acwing.cpp4133 行定义.

4133 {
4134 auto *str = new char[501];
4135 cin.getline(str, 501);
4136 str[strlen(str) - 1] = '\0';
4137 const char *longest_word = nullptr;
4138 int max_len = 0;
4139 for(const char *word = strtok(str, " "); word != nullptr; word = strtok(nullptr, " ")) {
4140 if(max_len < strlen(word)) {
4141 max_len = strlen(word);
4142 longest_word = word;
4143 }
4144 }
4145 cout << longest_word;
4146 delete[] str;
4147 return 0;
4148 }

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


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