خرید بک لینک

Vote count: -1

Guys i have to do this by midnight tonight, london time so i'm really in a hurry. I've searched the entire inteet for a solution and i tried every method offered but nothing works so i think asking a new question is fair.

Here's the thing: i have a struct ALUNO (means student in Portuguese) and when i initiate the program i want it to read the file with the students data into a linked list but i also want to be able to insert new nodes to the list with the method i've implemented. The code i found on the inteet, when i run it it just opens and writes nothing on the screen.

Here's my code:

(functions.h)

struct ALUNO {
    int codigo;
    int nasc[3];
    float plafond;
    string PNome;
    string UNome;
    string curso;
    string rua;
    int porta;
    string localidade;
    string distrito;
    string codigopostal;
    string password;
    string telefone;
    string nomecompleto;
    ALUNO *next;
};

(functions.cpp)

//new   
void novo(ALUNO *head)
    {
        head->next = NULL;
    }

    int vazia(ALUNO *head){
        if (head->next == NULL)
            retu 1;
        else
            retu 0;
    }

//ALOCATES ALUNO  
ALUNO *aloca(ALUNO *head) {
    setlocale(LC_ALL, "Portuguese");
    ALUNO *novo = new ALUNO;
    string verifica; //verificacao password


    system("CLS");
    baer();
    cout << "ntt----------------------------------------------------";
    cout << "ntt|                  INSERIR ALUNO                   |";
    cout << "ntt----------------------------------------------------" << endl;



    //USERNAME
    cout << "nttNota: O useame tem que ser um número inteiro";
    do {
        cout << "nttUseame: ";
        cin >> novo->codigo;
        novo->codigo = verificacaoInteiro(novo->codigo);
    } while (existeUseame(head, novo->codigo) != false);



    //PASSWORD
    novo->password = getpass("nttPassword: ", true); 
    verifica = getpass("nttInsira novamente a password: ", true);
    novo->password = verificacaoPasswordMatch(novo->password, verifica);


    system("CLS");
    baer();
    cout << "ntt----------------------------------------------------";
    cout << "ntt|                   INSERIR ALUNO                  |";
    cout << "ntt----------------------------------------------------";
    cout << "nttUSERNAME: " << novo->codigo << endl;


    cout << "nttPrimeiro nome: ";
    cin >> novo->PNome;

    transform(novo->PNome.begin(), novo->PNome.end(), novo->PNome.begin(), ::toupper); //transforma PNome em maiúsculas


    cout << "nttSobrenome: ";
    cin >> novo->UNome;
    transform(novo->UNome.begin(), novo->UNome.end(), novo->UNome.begin(), ::toupper); // transforma UNome em minusculas


    novo->nomecompleto = novo->PNome + " " + novo->UNome; //concatena .PNome com .UNome


    cin.ignore(std::numeric_limits<std::streamsize>::max(), 'n'); //serve para poder usar um getline depois de um cin

    cout << "nttCurso: ";
    getline(cin, novo->curso);
    transform(novo->curso.begin(), novo->curso.end(), novo->curso.begin(), ::toupper);

    cout << "nttTelefone: ";
    cin >> novo->telefone;
    cout << endl;

    cin.ignore(std::numeric_limits<std::streamsize>::max(), 'n');



    //MORADA
    system("CLS");
    baer();
    cout << "ntt----------------------------------------------------";
    cout << "ntt|                   INSERIR ALUNO                  |";
    cout << "ntt----------------------------------------------------";
    cout << "nttUSERNAME: " << novo->codigo << endl;

    cout << "nttMORADA" << endl << "nttRua: ";
    getline(cin, novo->rua);
    transform(novo->rua.begin(), novo->rua.end(), novo->rua.begin(), ::toupper);

    cout << "nttPorta: ";
    cin >> novo->porta;
    novo->porta = verificacaoInteiro(novo->porta);

    cin.ignore(std::numeric_limits<std::streamsize>::max(), 'n');

    cout << "nttLocalidade: ";
    getline(cin, novo->localidade);
    transform(novo->localidade.begin(), novo->localidade.end(), novo->localidade.begin(), ::toupper);

    cout << "nttDistrito: ";
    getline(cin, novo->distrito);
    transform(novo->distrito.begin(), novo->distrito.end(), novo->distrito.begin(), ::toupper);

    cout << "nttCodigo-Postal: ";
    cin >> novo->codigopostal;
    cout << endl;



    //DATA DE NASCIMENTO
    system("CLS");
    baer();
    cout << "ntt----------------------------------------------------";
    cout << "ntt|                   INSERIR ALUNO                  |";
    cout << "ntt----------------------------------------------------";
    cout << "nttUSERNAME: " << novo->codigo << endl;
    cout << "nttDATA DE NASCIMENTO" << endl << "nttDia: ";
    scanf_s("%d", &novo->nasc[0]);
    cout << "nttMes: ";
    scanf_s("%d", &novo->nasc[1]);
    cout << "nttAno: ";
    scanf_s("%d", &novo->nasc[2]);
    novo->plafond = 0.0;

    system("PAUSE");
    retu novo;
}

//INSERTS NODE TO THE LINKED LIST
void insereAluno(ALUNO *head){
    setlocale(LC_ALL, "Portuguese");
    ALUNO *novo = aloca(head);
    novo->next = NULL;

    if (vazia(head))
        head->next = novo;
    else {
        ALUNO *atual = head->next;

        while (atual->next != NULL)
            atual = atual->next;

        atual->next = novo;
    }
}

//READS FILE
ALUNO * leFicheiro(){
    //bool first = true;
    ifstream ficheiro;
    ficheiro.open("DadosAlunos.txt");
    //ALUNO *head = NULL;
    ALUNO* head;
    ALUNO* node;
    node = new ALUNO;
    head = node; // 'save' start of linked list
    while (!ficheiro.eof()) {
        //if (first)
        //{
        ficheiro >> node->codigo;
        ficheiro >> node->nasc[0];
        ficheiro >> node->nasc[1];
        ficheiro >> node->nasc[2];
        ficheiro >> node->porta;
        ficheiro >> node->plafond;
        getline(ficheiro, node->PNome);
        getline(ficheiro, node->UNome);
        getline(ficheiro, node->curso);
        getline(ficheiro, node->rua);
        getline(ficheiro, node->localidade);
        getline(ficheiro, node->distrito);
        getline(ficheiro, node->codigopostal);
        getline(ficheiro, node->password);
        getline(ficheiro, node->telefone);
        getline(ficheiro, node->nomecompleto);
        node->next = new ALUNO; // create new node
        node = node->next;
        /*temp->next = head;
        if(head==NULL) head = temp;
        head->next = NULL;*/
    }
    ficheiro.close();
    retu head;
}

(main.cpp)

int main() {
    setlocale(LC_ALL, "Portuguese");
    system("TITLE CANTINA UNIVERSITÁRIA - UMa");

    //ALUNO *head;/*  = new ALUNO;*/
    REFEICAO *head1 = new REFEICAO;
    novo(head);
    nova(head1);
    ALUNO *head = leFicheiro();
    login(head, head1);
    retu 0;
}

I have to do the same to the linked list REFEICAO (means meal in Portuguese) but if i can do it for ALUNO i'll do the same thing for REFEICAO.

My teacher suggested verify if it's the first node insert at head, if it's not i may want to create a pointer for the node before and for the next node but i can't seem to do it.

Please, somebody help?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 16 خرداد 1395 ساعت: 2:14

صفحه بندی