Stack - if(i%2!= 0 cin>> name cout<< name else cin>>name names.push(name while(names.empty cout<< names.top names.pop setNum

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <stack> #include <iostream> #include <string> # using namespace std; int main(){ stack<string> names; int n; int setNum=1; string name; cin >> n ; cout << "SET " << setNum << endl; while (n != 0){ for (int i=n; i=0; i--){
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (i%2 != 0){ cin >> name ; cout << name ; } else { cin >>name ; names.push(name); } } while (names.empty()){ cout << names.top(); names.pop(); } setNum++; cin >> n ; } }...
View Full Document

This note was uploaded on 05/03/2011 for the course CSCI 180 taught by Professor Goldwasser,m during the Fall '08 term at Saint Louis.

Ask a homework question - tutors are online