I work for a university and grade students' C++ code. For testing purposes, I need to remove students' main function from their code. Can someone help me come up with an AWK solution for this? I need to delete from "int main" to that matching ending curly brace "}". Students' main function looks something like this:
int main(){
Queue q1;
cout << "Queue created. Empty? " << boolalpha << q1.empty() << endl;
cout << "How many elements to add to the queue? ";
int numItems;
cin >> numItems;
for (int i = 1; i <= numItems; i++)
q1.enqueue(100*i);
cout << "Contents of queue:\n";
q1.display();
cout << "Queue q1 empty? " << q1.empty() << endl;
cout << "\nFront value in q1: " << q1.front() << endl << endl;
while (!q1.empty())
{
cout << "Remove front -- Queue contents: ";
q1.dequeue();
q1.display();
}
cout << "\nQueue q1 empty? " << q1.empty() << endl;
cout << "Now try to retrieve front value in q1" << endl;
cout << "Front value in q1?" << endl << q1.front() << endl;
cout << "\nNow Try to remove front of q1: " << endl;
q1.dequeue();
Queue myQueue;
myQueue.enqueue('A');
myQueue.enqueue('B');
myQueue.enqueue('C');
myQueue.enqueue('D');
myQueue.enqueue('X');
myQueue.dequeue();
myQueue.enqueue('X');
myQueue.enqueue('Z');
cout << myQueue.front() << endl;
myQueue.dequeue();
myQueue.dequeue();
myQueue.enqueue('A');
myQueue.enqueue('C');
cout << myQueue.front() << endl;
myQueue.printPrivateInfo();
myQueue.display();
cout << endl << myQueue.drop('C') << endl;
myQueue.display();
myQueue.printPrivateInfo();
cout << endl << myQueue.indexUsed(0) << endl;
myQueue.dump();
cout << myQueue.isSorted() << endl;}