Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ Attribute Parser

#include <bits/stdc++.h>using namespace std;int main(){int n, q,i;cin>>n>>q;string temp;vector<string> hrml;vector<string> quer;cin.ignore();for(i=0;i<n;i++){    getline(cin,temp);    hrml.push_back(temp);}for(i=0;i<q;i++){    getline(cin,temp);    quer.push_back(temp);}map<string, string> m;vector<string> tag;for(i=0;i<n;i++){    temp=hrml[i];    temp.erase(remove(temp.begin(), temp.end(), '"' ),temp.end());    temp.erase(remove(temp.begin(), temp.end(), '>' ),temp.end());    if(temp.substr(0,2)=="</")    {        tag.pop_back();    }    else    {        stringstream ss;        ss.str("");        ss<<temp;        string t1,p1,v1;        char ch;        ss>>ch>>t1>>p1>>ch>>v1;        string temp1="";        if(tag.size()>0)        {            temp1=*tag.rbegin();            temp1=temp1+"."+t1;        }        else            temp1=t1;        tag.push_back(temp1);        m[*tag.rbegin()+"~"+p1]=v1;        while(ss)        {            ss>>p1>>ch>>v1;            m[*tag.rbegin()+"~"+p1]=v1;        }    }}for(i=0;i<q;i++){    if (m.find(quer[i]) == m.end())        cout << "Not Found!
";    else        cout<<m[quer[i]]<<endl;}return 0;
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to check char array equality in C++ 
Cpp :: c++ program to convert celsius to kelvin 
Cpp :: operator precedence in cpp 
Cpp :: find text in string c++ true false 
Cpp :: User defined functions and variables in C++ programming 
Cpp :: C++ wchar_t 
Cpp :: hello world cc++ 
Cpp :: adddynamic ue4 c++ 
Cpp :: how to check if vector is ordered c++ 
Cpp :: Find duplicates in an array geeks for geeks solution in cpp 
Cpp :: cpp vscode multipe compilation 
Cpp :: glfw error: the glfw library is not initialized 
Cpp :: sliding window c++ 
Cpp :: c++ cin 
Cpp :: opencv(4.5.1) c:usersappveyorappdatalocal emp1pip-req-build-kh7iq4w7opencvmodulesimgprocsrc esize.cpp:4051: error: (-215:assertion failed) !ssize.empty() in function 
Cpp :: c ++ program to insert into hashmap 
Cpp :: c++ include < vs "" 
Cpp :: c++ awitch statements 
Cpp :: C++ vector at() method 
Cpp :: vector iterator in c++ 
Cpp :: C++ Taking Multiple Inputs 
Cpp :: C++ Vector Operation Change Elements 
Cpp :: Implicit conversion casting 
Cpp :: unordered_map in c++ 
Cpp :: cpprestsdk send file 
Cpp :: print numbers after decimal point c++ 
Cpp :: c++ *agrs 
Cpp :: input numbers to int c++ 
Cpp :: c++ take n number from the user and store them in array and get the max, min number of them and also find the average/summation of these numbers 
Cpp :: cpp module 42 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =