Drkcore

30 05 2008 cpp topcoder Tweet

SRM173-DIV2-500

splitができなくて難儀した。

というわけでxでsplit。substrで前から切り刻んでいく。

#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main(){
  string str = "..x..x.xxx.xxx.....x.x...x..x.x....x.x...";
  int cutAt;
  while( (cutAt = str.find_first_of('x')) != str.npos ){
    if(cutAt > 0)
      {
       cout << str.substr(0, cutAt).size() << endl;
      }
    str = str.substr(cutAt + 1);
  }
}

あーこれだと最後のstringは何もしないな。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021