Bot clean written on C++ First string includes 4 integers: N, M, A, B (1 ≤ N, M ≤ 300, A, B ≤ 1000).
Each next line include M-symbols. Symbol . is a clean cell, * and ** are dirty.

I need to find the sum for cleaning if A its sum of ** cell, B is sum of *.

What I can do better?

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using std::cin;
using std::cout;
using std::string;
using std::vector;

int main() {
  int n, m, a, b;
  cin &gt;&gt; n &gt;&gt; m &gt;&gt; a &gt;&gt; b;

  vector&lt;string&gt; parquet;

  int itr = 0;

  while (itr &lt; n) {
    string cell;
    cin &gt;&gt; cell;
    parquet.push_back(cell);
    itr++;
  }

  int sum = 0;

  itr = 0;

  while (itr &lt; parquet.size()) {
    for (int i = 0; i &lt; parquet[itr].size(); i++) {
      if (parquet[itr][i] == '*') {
        if (parquet[itr][i + 1] == '*') {
          i++;
          sum += a;
        } else {
          sum += b;
        }
      }
    }

    itr++;
  }

  cout &lt;&lt; sum;
}
You can refine your algorithm by getting rid of all these counters and while loops and replace them with a for loop such as this:

for (int i = 0; i &lt; parquet.size(); i++)
    parquet[i] = ... // do whatever


Similarly, you can re-write the summing algorithm as: 

for (int i = 0; i &lt; parquet.size(); i++){
    for (int j = 0; j &lt; parquet[i].size(); j++) {
      if (parquet[i][j] == '*') &amp;&amp; (parquet[i][j + 1] == '*') {
          j++;
          sum += a;
      else 
          sum += b;
      }
    }
}


That said, I notice you're naming your counters as "iter" (which I assume is a short for iterator). Are you trying to access your vector in a typical STL manner (i.e.: using iterators?). If that was your intent, you can try something like:

vector&lt;string&gt;::iterator myIterator;
for (myIterator = parquet.begin(); myIterator != parquet.end(); myIterator++)
// Do whatever


That is, of course, assuming your procedure works as intended. If not, please state otherwise.