Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "List.h"
- #include <vector>
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <iterator>
- #include <deque>
- #include <algorithm>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- // Create list
- List Borna;
- // Take input from user
- std::string input;
- getline(std::cin, input);
- // Seperate input by space, and put in cells in vector named inputvector that holds strings
- std::stringstream ss(input);
- std::istream_iterator<std::string> begin(ss);
- std::istream_iterator<std::string> end;
- std::vector<std::string> inputvector(begin, end);
- //std::cout << (inputvector.at(1)).at(0) << std::endl;
- for(unsigned long i = 0; i < inputvector.size(); i++)
- {
- // If input is R, then remove from head
- if (inputvector.at(i) == "R")
- {
- if (inputvector.at(0) == "R") {
- inputvector.at(0).erase(0, 1);
- continue;
- }
- //std::cout << "Removing value " << std::endl;
- Borna.RemoveFromHead();
- }
- // If input is not R, then it must be A; So, remove the A from the stringint combination
- // and add the integer to the node list
- else
- {
- (inputvector.at(i)).erase(0, 1);
- string s = inputvector.at(i);
- int x = 0;
- stringstream convert(s);
- convert>>x;
- //std::cout << "Adding value " << inputvector.at(i) << std::endl;
- Borna.AddNode(x);
- }
- }
- Borna.PrintList();
- //std::cout << "test" << std::endl;
- Borna.FindMiddle();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement