|
|
|
| сначала вы подумаете что я спятил, такой код сюда закидывать, но эт не так. прога работает, она список должна сортировать. только вот что-то в функции sort() пишет что не иденцифицирован элемент T.
чё за нафиг??? кому не лень гляньте...
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<math.h>
struct tsp1
{
char *s;
struct tsp1 *next1;
};
struct tsp2
{
char *ss;
struct tsp2 *next2;
};
class spisok
{
struct tsp1 *P1;
struct tsp2 *P2;
int n1,n2;
public:
spisok()
{
P1=NULL;
P2=NULL;
}
void vvod1()
{
char *Str;
tsp1 *Q;
Str=new char[50];
cout<<"vvod spis 1 vihod - ###"<<endl;
n1=0;
while(1)
{
gets(Str);
if(strstr(Str,"###"))
break;
Q=new tsp1;
Q->s=new char[strlen(Str)];
strcpy(Q->s,Str);
Q->next1=P1;
P1=Q;
n1++;
}
delete []Str;
}
void vvod2()
{
char *Str;
tsp2 *Q;
Str=new char[50];
cout<<"vvod spis 2 vihod - ###"<<endl;
n2=0;
while(1)
{
gets(Str);
if(strstr(Str,"###"))
break;
Q=new tsp2;
Q->ss=new char[strlen(Str)];
strcpy(Q->ss,Str);
Q->next2=P2;
P2=Q;
n2++;
}
delete []Str;
}
void vivod1()
{
tsp1 *Q;
cout<<endl<<"vivod spis 1"<<endl;
Q=P1;
for(int i=0;i<n1;i++)
{
puts(Q->s);
Q=Q->next1;
}
cout<<endl;
}
void vivod2()
{
tsp2 *Q;
cout<<endl<<"vivod spis 2"<<endl;
Q=P2;
for(int i=0;i<n2;i++)
{
puts(Q->ss);
Q=Q->next2;
}
cout<<endl;
}
void sort1()
{
tsp1 *Q;
char *str1,*str2,*str3;
str1=new char[10];
str2=new char[10];
str3=new char[10];
while(Q)
{
T=new tsp1;
if(Q->s>Q->next1->s)
{
T->s=Q->s;
Q->s=Q->next1->s;
Q->next1->s=T->s;
T->next1=Q->next1;
Q->next1=Q->next1->next1;
Q->next1->next1=T->next1;
}
Q=Q->next1;
}
}
};
int main()
{
spisok steck;
steck.vvod1();
steck.sort1();
steck.vvod2();
steck.vivod1();
steck.vivod2();
getch();
} | |
|
|
|
|
|
|
|
для: timaslook
(24.04.2007 в 18:19)
| | Следует задать тип объекту T, т.е. вместо
писать
| |
|
|
|