C/C++の宿題を片づけ作戦指令 30代目
■ このスレッドは過去ログ倉庫に格納されています
0073デフォルトの名無しさん
NGNG#include <iostream>
#include <string>
#include <cctype>
using std::string;
using std::isspace;
string trim (string str)
{
unsigned i = 0, j = str.length();
while (isspace(str[i]))
i++;
while (isspace(str[j]))
j--;
str.resize(j);
return string(str.c_str() + i);
}
int main(void)
{
for (;;)
{
string str;
std::cin >> str;
std::cout << trim(str) << std::endl;
}
return 0;
}
もしisblankがあればisspaceよりもそれを使う方がいい鴨
■ このスレッドは過去ログ倉庫に格納されています