Skip to content

Instantly share code, notes, and snippets.

@kittydoor
Last active May 6, 2017 15:17
Show Gist options
  • Save kittydoor/e917bc2aa1e72aa210d8cff9fa5e922b to your computer and use it in GitHub Desktop.
Save kittydoor/e917bc2aa1e72aa210d8cff9fa5e922b to your computer and use it in GitHub Desktop.
Project file
D301 Capacity 40
1 1 5
2 2 4
3 3 4
4
5 2
6
7 1
#include <fstream>
#include <iostream>
#include <queue>
void stoq(std::queue<char>& q, std::string s){
std::queue<char> empty;
std::swap(q, empty);
for(char ch : s){
if(!isspace(ch)){
q.push(ch);
}
}
}
std::string print_queue(std::queue<char> q){
std::cout << "Queue: ";
int i = 0;
while(!q.empty()){
std::cout << "i" << i;
i++;
std::cout << q.front();
q.pop();
}
std::cout << std::endl;
}
int main(){
std::fstream infile("D301.txt");
std::string line;
std::queue<char> q;
std::getline(infile, line);
stoq(q, line);
print_queue(q);
std::string classroom_name;
while(q.front() != 'C'){
classroom_name += q.front();
q.pop();
}
for(int i=0; i<8; i++){
q.pop();
}
std::string capacity_str;
while(!q.empty()) {
capacity_str += q.front();
q.pop();
}
int capacity = stoi(capacity_str);
std::getline(infile, line);
while(infile){
std::getline(infile, line);
std::cout << "fl" << std::endl;
stoq(q, line);
std::cout << "sl" << std::endl;
print_queue(q);
std::cout << "tl" << std::endl;
}
infile.close();
/*while(infile){
std::string line;
std::getline(infile, line);
for(char ch : line){
file.push(ch);
}
file.push('$');
}
file.push('%');
while(file.peek() != '%'){
}*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment