View Code of Problem 98

#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,str,name;
	int f,d;
	while(getline(cin,s)&&s!="</xmp>"){
		str=s.substr(0,4);
		if(str=="<h3 "){
			f=0;
			d=0;
			s.erase(0,1);
			name=s.substr(s.find('>')+1,s.find('<')-s.find('>')-1);
		}
		else if(str=="<li>"){
			d++;
			if(s.find("In Stock")!=s.npos)
			f=1;
			if(d==4){
				if(f)
				cout<<name<<endl;
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 98