0% found this document useful (0 votes)
13 views1 page

C++ Nini

Uploaded by

tsulaianini6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

C++ Nini

Uploaded by

tsulaianini6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <iostream>

#include <vector>
#include <algorithm>

using namespace std;

int main() {
vector<string> stringVector;
string input;

while (cin >> input) {


stringVector.push_back(input);
}

vector<int> numericalVector;

for (size_t i = 0; i < stringVector.size(); ++i) {


const string& str = stringVector[i];

size_t startPos = str.find("ann");


if (startPos != string::npos) {
size_t endPos = startPos + 2;

int sum = static_cast<int>(startPos) + static_cast<int>(endPos);


numericalVector.push_back(sum);
}
}

sort(numericalVector.rbegin(), numericalVector.rend());

for (size_t i = 0; i < numericalVector.size(); ++i) {


int value = numericalVector[i];
cout << value << " ";
}

return 0;
}

You might also like