View Code of Problem 98

#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	string name;
	int flag = 0;
	while (getline(cin, s)) {
		if (s == "</xmp>") {
			return 0;
		}
		if (s.substr(0, 3) == "<h3") {
			size_t start = s.find(">") + 1;
			name = s.substr(start);
			size_t end = name.find("<");
			name = name.substr(0, end);

			for (int i = 0; i < 4; ++i) {
				getline(cin, s);
				if (s.find("In Stock") != string::npos) {
					flag = 1;
				}
			}

			if (flag == 1) {
				flag = 0;
				cout << name << endl;
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 98