2009-07-26から1日間の記事一覧

string -> int キャスト

C++

ようするに、1文字ずつ cast したらいいのかもしれないんだけど。 で、あれですね、static_cast(char) の場合、1文字が、asciiコードになるので、「 - '0'」とかしてやると数値になるわけですね。で、文字列をintにしてやろう、とか考えると、 #include <iostream> #in</iostream>…

string

C++

#include <iostream> #include <sstream> #include <string> using namespace std; int main() { string hoge = "hoge", fuga = "fuga"; // some method of std::string cout << hoge << endl; cout << hoge.length() << endl; cout << hoge.at(1) << endl; cout << hoge.substr(1,2) <<</string></sstream></iostream>…

SRM 146 DIV 1 300

はつとっぷこーだ。まあpracticeだけど。