我已经使用单链表编写了结构。 孔错误列表: 我已经使用单链表编写了结构。所以我的任务是使用C而不是C ++。 孔错误列表:
40 [错误]未在此范围内声明“ printselect”
45 [错误]在此范围内未声明“ traincreation”
46 [错误]在此范围内未声明“ trainfind”
47 [错误]在此范围内未声明“ trainsort”
48 [错误]未在此范围内声明“ trainchange”
49 [错误]在此范围内未声明“ addtobegining”
50 [错误]未在此范围内声明“ addtoend”
51 [错误]在此范围内未声明'deletetrain'
52 [错误]未在此范围内声明“ traininsert” 53 [错误]未在此范围内声明“ trainshow”
54 [错误]未在此范围内声明“ trainlastelement”
55 [错误]未在此范围内声明“大小” 56 [错误]未在此范围内声明“ trainsplit”
57 [错误]未在此范围内声明“质量”
58 [错误]在此范围内未声明“ trainfulldeleter”
59 [错误]未在此范围内声明“退出”
在函数'int traincreation(std :: list&)'中:
88无法通过'...'传递非平凡复制类型'std :: string {aka class std :: basic_string}'的对象
89 [错误]无法通过'...'传递非平凡复制类型'std :: string {aka class std :: basic_string}'的对象
90 [错误]无法通过'...'传递非平凡复制类型'std :: string {aka class std :: basic_string}'的对象
92 [错误]没有匹配的函数调用'std :: list :: push_back()'
92 [注意]候选人是:
100 [错误]无法通过'...'传递非平凡复制类型'std :: string {aka class std :: basic_string}'的对象
104 [错误]“结构训练”没有名为“名称”的成员
108 [错误]在此范围内未声明'nazn'
110 [错误]在此范围内未在函数'void trainsort(std :: list&)'中声明'time':
120 [错误]在此范围内未声明“质量”在函数“ void trainchange(std :: list&)”中:
128 [错误]在此范围内未声明“ nazn”
129 [错误]在此范围内未声明'num'
130 [错误]未在此范围中声明“时间”
136 [错误]无法通过'...'传递非平凡复制类型'std :: string {aka class std :: basic_string}'的对象
137 [错误]无法通过'...'传递非平凡复制类型'std :: string {aka class std :: basic_string}'的对象
138 [错误]无法通过'...'传递非平凡复制类型'std :: string {aka class std :: basic_string}'的对象
139 [错误]没有匹配的函数调用'std :: list :: push_front()'
#include<string> // 1
#include<algorithm> // 2
#include<list> // 3
#include<iterator> // 4
#include<stdio.h> // 5
using namespace std; // 6
// 7
struct Train{ // 8
char nazn[7]; // 9
unsigned int num; // 10
char time [7]; // 11
bool quality(const Train& p1, const Train& p2) // 12
{ // 13
return p1.time < p2.time; // 14
} // 15
void printselect(); // 16
int traincreation(list<Train> &l); // 17
void trainfind(list<Train> &trnl); // 18
void trainsort(list<Train> &trnl); // 19
void trainchange(list<Train> &trnl); // 20
void addtobegining(list<Train> &l); // 21
void addtoend(list<Train> &l); // 22
void traininsert(list<Train> &l); // 23
void deletetrain(list<Train> &l); // 24
void trainshow(list<Train> &trnl); // 25
void trainlastelement(list<Train> &l); // 26
void trainsplit(list<Train> &l, list<Train> &l1); // 27
void trainfulldeleter(list<Train> &l, list<Train> &l1); // 28
void quit(); // 29
}; // 30
int main() // 31
{ // 32
std::list<Train> trnl; // 33
std::list<Train>trnl1; // 34
std::list<Train>::iterator beg=trnl.begin(); // 35
std::list<Train>::iterator fin=trnl.end(); // 36
int select; // 37
while (1) // 38
{//39
printselect(); // 40
printf("Select your number:"); // 41
scanf("%d",&select); // 42
switch(select) // 43
{ // 44
case 1:traincreation(trnl); break; // 45
case 2:trainfind(trnl); break; // 46
case 3:trainsort(trnl); break; // 47
case 4:trainchange(trnl); break; // 48
case 5:addtobegining(trnl); break; // 49
case 6:addtoend(trnl); break; // 50
case 7:deletetrain(trnl); break; // 51
case 8:traininsert(trnl); break; // 52
case 9:trainshow(trnl); break; // 53
case 10:trainlastelement(trnl1); break; //54
case 11:printf("The volume of the list is :"); (trnl,size);break;//55
case 12:trainsplit(trnl, trnl1); break; //56
case 13:printf("\n\t Proccesing the effect spliting.\n"); trnl.merge(trnl1, quality); break; //57
case 14:trainfulldeleter(trnl,trnl1); break; //58
case 15: quit(); break; //59
default: printf("\tWrong comand. Check the number for input.\n"); break; // 60
} //61
} //62
};//63
void printselect()//64
{//65
printf("\n\t1\tCreating the list and adding elements\n");//66
printf("\t2\tFound the element\n");//67
printf("\t3\tSort objects by the addres\n");//68
printf("\t4\tChange the list \n");//69
printf("\t5\tAdd a list to the begining \n");//70
printf("\t6\tAdd a list to the end\n");//71
printf("\t7\tDelete an list part \n");//72
printf("\t8\tInsert the list\n");//73
printf("\t9\tShow all the elements \n");//74
printf("\t10\tIndetification of the last element in list\n");/75
printf("\t11\tIndetification of lenght of the list\n");//76
printf("\t12\tBreaking list on two parts\n");//77
printf("\t13\tMergering of two parts\n");//78
printf("\t14\tDelete the memory\n");//79
printf("\t15\tExit\n");//80
};//81
int traincreation(list<Train> &l) //82
{//83
int a;//84
scanf("%s",a);//85
string nazn1,num1,time1;//86
for(int i = 0;i<a;i++){//87
printf("\n\t Enter your destination:",i+1);scanf("%s",nazn1);//88
printf("\n\t Enter the train number:",i+1);scanf("%d",num1);//89
printf("\n\t Enter the departure time:", i+1);scanf("%s",time1);//90
printf("\n----------------------------------------------------\n");//92
l.push_back({nazn1,num1,time1}); //93
}//94
}//95
void trainfind(list<Train> &trnl)//96
{//97
string plot;//98
int i=1;//99
printf("\n\t Enter the element to find:");//100
scanf("%s", plot);//101
std::list<Train>::iterator beg;//101
for(beg=trnl.begin(); beg!=trnl.end(); beg++)//102
{//103
if(beg->name == plot)//104
{//105
printf("\n\tThis element is real:");//106
printf("\n\tThe number of the element:");scanf("%s", i);//107
printf("\n\tThe destination:");advance(beg, nazn);//108
printf("\n\tThe number:");advance(beg, nazn);//109
printf("\n\tThe time :");advance(beg, time);//110
}//111
i++;//112
}//113
printf("\n\tSelected object isnt found");//114
}//115
//116
void trainsort(list<Train> &trnl)//117
{//118
printf("\n\t Sort is complited.");//119
trnl.sort(quality);//120
}//121
//122
void trainchange(list<Train> &trnl)//123
{//123
list<Train>::iterator beg=trnl.begin();//124
int v;//125
printf("\n\t Enter the index of element to change");scanf("%s", v);advance(beg, v);//126
printf("\n\t Enter your destination:");scanf("%s", nazn);advance(beg, nazn);//127
printf("\n\t Enter the train number:");scanf("%d", num);advance(beg, num);//128
printf("\n\t Enter the departure time:");scanf("%s", time);advance(beg, time);//129
}//130
//131
void addtobegining(list<Train> &l)//132
{//133
string nazn1, num1, time1;//134
printf("\n\t Enter the destination:");scanf("%s", nazn1);//135
printf("\t Enter the number:");scanf("%d", num1);//136
printf("\t Enter the time:");scanf("%s", time1);//137
l.push_front({nazn1, num1, time1});//138
}//138
//139
void addtoend(list<Train> &l)
{
string nazn1, num1, time1;
printf("\n\t Enter the destination:");scanf("%s", nazn1);
printf("\t Enter the number:");scanf("%d", num1);
printf("\t Enter the time:");scanf("%s", time1);
l.push_back({nazn1, num1, time1});
}
void traininsert(list<Train> &l)
{
int v;
std::list<Train>::iterator beg=l.begin();
string nazn1, num1, time1;
printf("\n\t Enter index to implement element:");scanf("%s", v);
printf("\t Enter the new destination:");scanf("%s", nazn1);
printf("\t Enter the new number:");scanf("%d", num1);
printf("\t Enter the new time:");scanf("%s", time1);
advance(beg, v);
l.insert(beg,{nazn1, num1, time1});
}
void deletetrain(list<Train> &l)
{
int v;
std::list<Train>::iterator beg=l.begin();
printf("\n\t Enter the index of element to delete:");scanf("%s", v);
printf("\n\t The element is deleted.");
advance(beg, v);
l.erase(beg);
}
void trainshow(list<Train> &trnl)
{
int v=1;
std::list<Train>::iterator beg;
printf("\n\t List of trains");
for(beg=trnl.begin(); beg!=trnl.end(); beg++)
{
printf("\n\t Index of the element:");scanf("%s", v);
printf("\n\t Destination saved in memory:");scanf("%s", &*beg);
printf("\n\t Name of the destination:");advance(beg, nazn);
printf("\n\t Number of the train:");advance(beg, num);
printf("\n\t Time of the destination :");advance(beg, time);
printf("\n\t ----------------------------------------------------------------");
v++;
}
}
void muzeumlastelement(list<Train> &l)
{
std::list<Train>::iterator beg=l.end();
beg--;
printf("\n\t Addres of the last element:");scanf("%s", &*beg);
}
void trainsplit(list<Train> &l, list<Train> &l1)
{
std::list<Train>::iterator beg=l.begin();
std::list<Train>::iterator last=l.end();
int v;
printf("\n\t Enter the starting index to split the list:\n");scanf("%s", v);
advance(beg,v);
l1.splice(l1.begin(), l, beg, last);
printf("\n\t The first list after splice :\n");
trainshow(l);
printf("\n\t The second part of the spliced list :");
trainshow(l1);
}
void trainfulldeleter(list<Train> &l, list<> &l1)
{
printf("\n\t All elements are depleted.\n");
l.clear();
l1.clear();
}
void quit()
{
printf("\tYou are sure that you want to quit? y/n : ");
char select1;
do
{
scanf("%c", &select1);
}
while (select1!='y' && select1 == 'n');
if(select1=='y')
{
exit(0);
}
return;
};