-4
我有關於工作人員數據的一般性工作以及我的方式,因爲我仍然存在此錯誤。如果有人願意幫助我請。 這是代碼索裏的郎是阿爾巴尼亞:insertAsFristElement未在此範圍內聲明
#include <iostream>
using namespace std;
struct pun{
char Emri[20];
char Mbiemri[20];
int Mosha , ID;
char Vendlindja[20];
char Arsimi[30];
int Datpunesim;
int Eksperienca;
int Datepushimi;
pun *next;
};
bool isEmpty(pun *head);
char menu();
void insertAsFristElement(pun *&head, pun *&last, int ID);
void insert (pun *&head, pun *&last, int ID);
void remove (pun *&head, pun *&last);
void showlist(pun *¤t);
bool isEmpty (pun *head){
if (head == NULL)
return true;
else
return false;
}
char menu(){
char choice ;
cout <<"Menuja...\n";
cout <<"1. Fusni te dhenat:...\n";
cout <<"2. Fshini te dhenat:...\n";
cout <<"3. Shfaqe Listen:...\n";
cout <<"4. Dil....\n";
cin >> choice;
return choice;
}
void insertAsFristElement(pun *&head, pun *&last, int ID){
pun *temp = new pun;
temp->ID = ID;
temp->next = NULL;
head = temp;
last = temp;
}
void insert (pun *&head, pun *&last, int ID){
if (isEmpty(head))
insertAsFirstElement(head,last,ID);
else{
pun *temp = new pun;
temp->ID = ID;
temp->next = NULL;
last->next = temp;
last = temp;
}
}
void remove (pun *&head, pun *&last){
if(isEmpty(head))
cout <<"Lista eshte boshe.\n";
else if (head==last){
delete head;
head = NULL;
last = NULL;
}
else{
pun *temp=head;
head = head->next;
delete temp;
}
}
void showlist(pun *¤t){
if (isEmpty(current))
cout<< "Lista eshte boshe :.....\n";
else{
cout <<"Permbajtja e Listes :...\n";
while (current!=NULL){
cout <<current->ID <<endl;
current = current->next;
}
}
}
int main(){
pun *head=NULL;
pun *last=NULL;
char choice;
int ID;
int n;
pun x[n];
do {
choice = menu();
switch (choice){
case '1': for (int i=1;i<n;i++){
cout<<"Vendosni ID e personit:....";
cin>>x[i].ID;
cout<<"Vendosni Emrin:......\n";
cin>>x[i].Emri;
cout<<"Vendosni Mbiemrin:....\n";
cin>>x[i].Mbiemri;
cout<<"Vendosni moshen:....\n";
cin>>x[i].Mosha;
cout<<"Vendosni vendlindjen:....\n";
cin>>x[i].Vendlindja;
cout<<"Vendosni Arsimin:.....\n";
cin>>x[i].Arsimi;
cout<<"Vendosni Eksperiencen:.....\n";
cin>>x[i].Eksperienca;
cout<<"Vendosni Daten e punesimit:....\n";
cin>>x[i].Datpunesim;
cout<<"Vendosni Daten e pushimit:.....\n";
cin>>x[i].Datepushimi;
insert(head,last,ID);
break;
}
case '2': remove (head,last);
break;
case '3':showlist(head);
break;
default : cout <<"Po dilni nga sistemi ..........\n";
}
}
while (choice !='4');
return 0;
}
請仔細檢查拼寫。 – molbdnilo
你拼錯了:'insertAsFirstElement()'它應該在所有情況下。 –
你說我應該把insertAsFirstElement()在所有情況下它沒有任何意義 –