2
My doubt is in the case 1
, how to include items in the queue, in case, mat
and media
. Follows code below:
#include <iostream>
#include <cstdlib>
#define tamanho 20
using namespace std;
struct Aluno{
int mat;
float media;
};
struct FILA{
int inicio;
int fim;
int item [tamanho];
};
int main(){
Aluno a;
FILA f;
int op;
cout << "-------------------------------------" << endl;
cout << "- 1 - Inserir Aluno ----" << endl;
cout << "- 2 - Exibir dados do Aluno ----" << endl;
cout << "- 3 - Aluno aprovados ----" << endl;
cout << "- 4 - Remover Aluno ----" << endl;
cout << "- 9 - Sair ----" << endl;
cout << "-------------------------------------" << endl;
cout << "Selecione a opção desejada: ";
cin >> op;
system("cls");
switch(op){
case 1:
system("cls");
cout<<"\nMatricula: "<<endl;
cin>>a.mat;
cout<<"\nMedia: "<<endl;
a.media;
enfileira(f, a.mat, a.media);
break;
case 9:
system("cls");
cout<<"\nPROGRAMA FINALIZADO !!!"<<endl;
return 0;
}
}
void iniciaFila(FILA &f) {
f.inicio = 0;
f.fim=f.inicio;
}
bool filaVazia(FILA f){
return f.fim==0;
}
bool filaCheia(FILA f){
return f.fim==tamanho;
}
void enfileira(FILA &f, int x){
if(!filaCheia(f))
f.item[f.fim++]=x;
else
cout<<"fila cheia\n";
}
void desenfileiraf(FILA &f){
if(!filaVazia(f)){
cout<<"desenfileirou "<<f.item[f.inicio]<<endl;
for(int i=0;i<f.fim-1;i++)
f.item[i]=f.item[i+1];
f.fim--;
}
else
cout<<"fila vazia\n";
}
int desenfileira(FILA &f){
if(!filaVazia(f)){
int n=f.item[f.inicio];
for(int i=0;i<f.fim-1;i++)
f.item[i]=f.item[i+1];
f.fim--;
return n;
}
cout<<"fila vazia\n";
return -1;
}
void mostra(FILA f){
if(!filaVazia(f)){
for(int i=f.inicio;i<f.fim;i++)
cout<<f.item[i]<<' ';
cout<<endl;
}
else
cout<<"fila vazia\n";
}
The exercise consists mainly of what the menu asks for.
I edited your question. When you are going to post some code, select it in your question and click on the icon
{}
in the menu. So you have a differentiation of what is text and what is code.– Rafael Barbosa
I clicked but did not select, thank you.
– André Cavalcante
I think Voce could put more writing so that someone can help you
– Otto