Created
March 28, 2011 00:24
-
-
Save ProgDan/889805 to your computer and use it in GitHub Desktop.
Revisions
-
ProgDan created this gist
Mar 28, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ #include <iostream> #include <queue> using namespace std; int menu(){ int op; cout << "Menu" << endl; cout << endl << "1) Inserir elemento na fila"; cout << endl << "2) Remover elemento da fila"; cout << endl << "3) Exibir primeiro da fila"; cout << endl << "4) Exibir último da fila"; cout << endl << "0) Sair"; cout << endl << endl << "Qual sua opção? "; cin >> op; cout << endl; return op; } void Inserir(queue<int> &F){ int v; cout << "Qual o valor a ser inserido na fila? "; cin >> v; F.push(v); } int Remover(queue<int> &F){ int x; x = F.front(); return x; } int Primeiro(queue<int> &F){ return F.back(); } int main(int argc, char *argv[]){ queue<int> F; int op, x; do { op = menu(); if (op >= 2 && op <= 4 && F.empty()){ cout << "File vazia" << endl; system("pause"); } else switch (op){ case 1: Inserir(F); break; case 2: x = Remover(F); cout << "Valor " << x << " removido da fila" << endl; system("pause"); break; case 3: x = Primeiro(F); cout << "Primeiro da fila: " << x << endl; system("pause"); break; case 4: x = Ultimo(F); cout << "Ultimo da fila: " << x << endl; system("pause"); break; } } while(op != 0); return 0; }