#include "stdafx.h"
#include<iostream>
#include<fstream>
#include<stack>
#include "URLContainer.h"
using namespace std;
bool isBalanced(string p){
stack<char> s;
for (int i =0 ;i < p.size(); i++){
if (p[i] == '(')
s.push('(');
else if (p[i] == ')') {
if (s.empty())
return false;
else s.pop();
}
}
if (s.empty())
return true;
return false;
}
int main(int argc, char* argv[])
{
string line;
getline(cin, line); if (isBalanced(line)) cout << "Its a Balanced expression" << endl;
else
cout << "It is NOT Balanced" << endl;
ifstream opendir("//Engr_asu/ECE352/computer_science.txt");
if (opendir == 0) {
cout << "Could not open input file" << endl;
}
URLContainer uc(opendir);
cout << "There were " << uc.size() << " URLs"<< endl;
uc.printFirstN(cout, 3);
uc.printNth(cout, 11);
uc.sortByURL(); cout << "===First three, sorted by URL" << endl;
uc.printFirstN(cout, 3);
uc.sortByTitle();
cout << "===First three, sorted by title" << endl;
uc.printFirstN(cout, 3);
return 0;
}