êóðñîâûå,êîíòðîëüíûå,äèïëîìû,ðåôåðàòû
̳í³ñòåðñòâî îñâ³òè ³ íàóêè Óêðà¿íè
Çàïîð³çüêèé íàö³îíàëüíèé óí³âåðñèòåò
Êàôåäðà ³íôîðìàö³éíèõ òåõíîëîã³é
²íäèâ³äóàëüíà ðîáîòà
Ç òåìè: «Ñ++. Êëàñè ³ îá’ºêòè»
Âèêîíàâ:
ñòóä. 2 êóðñó
ìàòåì. ô-òó
ãð. 8226-1
Ëàï³í Ñ.Ì.
Ïåðåâ³ðèâ:
Áîðþ Ñ.Þ.
Çàïîð³ææÿ 2007
Öåëü: Ðàçðàáîòêà ïðîñòåéøèõ êëàññîâ íà ïðèìåðå ðàçðàáîòêè ìîäåëåé ýëåìåíòàðíûõ îáúåêòîâ è äèíàìè÷åñêèõ èíôîðìàöèîííûõ ñòðóêòóð (îäíî è äâóíàïðàâëåííûõ ñïèñêîâ).
1 ÷àñòü ðàáîòû "ðàçðàáîòêà ïðîñòûõ êëàññîâ"
Ïîñòàíîâêà çàäà÷è
Ðàçðàáîòàòü êëàññ, íàáîð ìåòîäîâ (êîíñòðóêòîð è ìèíèìóì äâà ìåòîäà) äëÿ ïðîãðàììíîé ìîäåëè çàäàííîãî îáúåêòà. Îïèñàíèå îáúåêòà è åãî îñíîâíûõ ñâîéñòâ ïðèâîäèòñÿ íèæå. Ðàçðàáîòàòü âûçûâàþùóþ ïðîãðàììó (main), èñïîëüçóþùåé îáúåêòû ðàçðàáîòàííîãî êëàññà è òåñòèðóþùèå ðàáîòîñïîñîáíîñòü âñåõ ìåòîäîâ.
Âàðèàíòû çàäàíèé
14. Îáúåêò «ïðÿìîóãîëüíèê çàäàííûé äëèíàìè äâóõ ñòîðîí». Ïðåäóñìîòðåòü âîçìîæíîñòü îïåðàöèè ïðèñâàèâàíèÿ, îïðåäåëåíèÿ ïëîùàäè è ïåðèìåòðà, à òàê æå ëîãè÷åñêèé ìåòîä, îòâå÷àþùèé íà âîïðîñ – ÿâëÿåòñÿ ëè ïðÿìîóãîëüíèê êâàäðàòîì. Êîíñòðóêòîð äîëæåí ïîçâîëèòü ñîçäàâàòü îáúåêòû áåç è ñ íà÷àëüíîé èíèöèàëèçàöèåé.
Ïðîãðàìà:
#ifndef rectangle__h
#define rectangle__h
#include <math.h>
class rectangle
{
private:
double a, b;
public:
rectangle();
rectangle(double, double);
~rectangle();
rectangle & operator=(const rectangle & x);
double square(void);
double perimeter(void);
double diagonal(void);
int is_square(void);
void print_rectangle(void);
};
#endif
#ifndef conrectangle__h
#define conrectangle__h
#include <iostream.h>
#include "rectangle.h"
rectangle::rectangle()
{
cout<<"The constructor \"rectangle()\" worked.\n";
a=1.0;
b=1.0;
};
rectangle::rectangle(double x, double y)
{
cout<<"The constructor \"rectangle(double, double)\" worked.\n";
a=x;
b=y;
};
rectangle::~rectangle()
{
cout<<"The destructor \"~rectangle()\" worked.\n";
a=0.0;
b=0.0;
};
rectangle & rectangle::operator=(const rectangle & x)
{
if(this==&x) return *this;
this->a=x.a;
this->b=x.b;
return *this;
};
double rectangle::square(void)
{
return a*b;
};
double rectangle::perimeter()
{
return 2*a+2*b;
};
double rectangle::diagonal()
{
return sqrt(a*a+b*b);
};
int rectangle::is_square()
{
if(a==b) return 1;
return 0;
};
void rectangle::print_rectangle()
{
char msg1[]=" ", msg2[]=" not ";
cout<<"a="<<a<<" b="<<b;
cout<<"\nS= "<<square()<<" m^2 P="<<perimeter()<<" m d="<<diagonal()<<" m";
cout<<"\nRectangle is";
if(is_square())
cout<<msg1;
else
cout<<msg2;
cout<<"square.\n";
return;
};
#endif
#include <iostream.h>
#include "conrectangle.h"
void main()
{
rectangle r1;
double a,b;
char s[1];
cout<<"\nESLI VAM ETA PROGA POKAZHETSA TUPOY... NE PEREZHYVAITE! ETO DEISTVITEL'NO TAK :)\n";
do
{
cout<<"\n Our rectangle:\n";
r1.print_rectangle();
cout<<"Input a, b:\n";
cin>>a>>b;
rectangle r2(a, b);
cout<<"\n Your rectangle:\n";
r2.print_rectangle();
r1=r2;
cout<<"\n Your rectangle is our now:\n";
r1.print_rectangle();
cout<<"Repeat or quit?(r/q)...";
cin>>s;
}
while (s[0]!='q');
return;
};
Ðåçóëüòàòè:
D:\Studies\Labs\Cpp\Individ_6>ind1
The constructor "rectangle()" worked.
ESLI VAM ETA PROGA POKAZHETSA TUPOY... NE PEREZHYVAITE! ETO DEISTVITEL'NO TAK :)
Our rectangle:
a=1 b=1
S= 1 m^2 P=4 m d=1.41421 m
Rectangle is square.
Input a, b:
456.125
789.5452485
The constructor "rectangle(double, double)" worked.
Your rectangle:
a=456.125 b=789.545
S= 360131 m^2 P=2491.34 m d=911.829 m
Rectangle is not square.
Your rectangle is our now:
a=456.125 b=789.545
S= 360131 m^2 P=2491.34 m d=911.829 m
Rectangle is not square.
Repeat or quit?(r/q)...r
The destructor "~rectangle()" worked.
Our rectangle:
a=456.125 b=789.545
S= 360131 m^2 P=2491.34 m d=911.829 m
Rectangle is not square.
Input a, b:
0.4876
0.4876
The constructor "rectangle(double, double)" worked.
Your rectangle:
a=0.4876 b=0.4876
S= 0.237754 m^2 P=1.9504 m d=0.689571 m
Rectangle is square.
Your rectangle is our now:
a=0.4876 b=0.4876
S= 0.237754 m^2 P=1.9504 m d=0.689571 m
Rectangle is square.
Repeat or quit?(r/q)...r
The destructor "~rectangle()" worked.
Our rectangle:
a=0.4876 b=0.4876
S= 0.237754 m^2 P=1.9504 m d=0.689571 m
Rectangle is square.
Input a, b:
16.23
31.06
The constructor "rectangle(double, double)" worked.
Your rectangle:
a=16.23 b=31.06
S= 504.104 m^2 P=94.58 m d=35.0448 m
Rectangle is not square.
Your rectangle is our now:
a=16.23 b=31.06
S= 504.104 m^2 P=94.58 m d=35.0448 m
Rectangle is not square.
Repeat or quit?(r/q)...q
The destructor "~rectangle()" worked.
The destructor "~rectangle()" worked.
D:\Studies\Labs\Cpp\Individ_6>
2 ÷àñòü ðàáîòû «Èíôîðìàöèîííûå äèíàìè÷åñêèå ñòðóêòóðû»
Ïîñòàíîâêà çàäà÷è
Íàïèñàòü ïðîãðàììó, â êîòîðîé ñîçäàþòñÿ äèíàìè÷åñêèå ñòðóêòóðû, è âûïîëíèòü èõ îáðàáîòêó â ñîîòâåòñòâèè ñî ñâîèì âàðèàíòîì.
Äëÿ êàæäîãî âàðèàíò ðàçðàáîòàòü ñëåäóþùèå ìåòîäû:
1. Êîíñòðóêòîð ïóñòîãî ñïèñêà.
2. Äîáàâëåíèå ýëåìåíòà â ñïèñîê (â ñîîòâåòñòâèè ñî ñâîèì âàðèàíòîì).
3. Óäàëåíèå ýëåìåíòà èç ñïèñêà (â ñîîòâåòñòâèè ñî ñâîèì âàðèàíòîì).
4. Ïå÷àòü ñïèñêà.
5. Çàïèñü ñïèñêà â ôàéë.
6. Âîññòàíîâëåíèå ñïèñêà èç ôàéëà.
7. Äåñòðóêòîð ñïèñêà (óíè÷òîæåíèå).
Ïîðÿäîê âûïîëíåíèÿ ðàáîòû
1. Ðàçðàáîòàòü îïèñàíèå êëàññà, âûäåëèòü ïóáëè÷íûå è ïðèâàòíûå ïîëÿ äàííûõ. Ðàçðàáîòàòü èíòåðôåéñ êëàññà – ïðîòîòèïû ìåòîäîâ.
2. Íàïèñàòü ôóíêöèþ äëÿ ñîçäàíèÿ ñïèñêà. Ôóíêöèÿ ìîæåò ñîçäàâàòü ïóñòîé ñïèñîê, à çàòåì äîáàâëÿòü â íåãî ýëåìåíòû.
3. Íàïèñàòü ôóíêöèþ äëÿ ïå÷àòè ñïèñêà. Ôóíêöèÿ äîëæíà ïðåäóñìàòðèâàòü âûâîä ñîîáùåíèÿ, åñëè ñïèñîê ïóñòîé.
4. Íàïèñàòü ôóíêöèè äëÿ óäàëåíèÿ è äîáàâëåíèÿ ýëåìåíòîâ ñïèñêà â ñîîòâåòñòâèè ñî ñâîèì âàðèàíòîì.
5. Âûïîëíèòü èçìåíåíèÿ â ñïèñêå è ïå÷àòü ñïèñêà ïîñëå êàæäîãî èçìåíåíèÿ.
6. Íàïèñàòü ôóíêöèþ äëÿ çàïèñè ñïèñêà â ôàéë.
7. Íàïèñàòü ôóíêöèþ äëÿ óíè÷òîæåíèÿ ñïèñêà.
8. Çàïèñàòü ñïèñîê â ôàéë, óíè÷òîæèòü åãî è âûïîëíèòü ïå÷àòü (ïðè ïå÷àòè äîëæíî áûòü âûäàíî ñîîáùåíèå "Ñïèñîê ïóñòîé").
9. Íàïèñàòü ôóíêöèþ äëÿ âîññòàíîâëåíèÿ ñïèñêà èç ôàéëà.
10. Âîññòàíîâèòü ñïèñîê è ðàñïå÷àòàòü åãî.
11. Óíè÷òîæèòü ñïèñîê.
Âàðèàíòû çàäàíèé
14. Çàïèñè â ëèíåéíîì ñïèñêå ñîäåðæàò ïîëå äàííûõ çâåíà òèïà *char(ñòðîêà ñèìâîëîâ). Ñôîðìèðîâàòü äâóíàïðàâëåííûé ñïèñîê. Óäàëèòü èç íåãî Ê ýëåìåíòîâ ñ óêàçàííûìè íîìåðàìè. Äîáàâèòü Ê ýëåìåíòîâ ñ óêàçàííûìè íîìåðàìè.
Ïðîãðàìà:
#ifndef list_h
#define list_h
class list
{
private:
struct element
{
char* info;
element* up;
element* down;
};
element *first, *last, *current;
public:
list(); //constructor
~list(); //destructor
void del_list(); //ochishchajet spisok
void init_list(int,char*); //initsializatsia spiska fonarhym metodom
void print_list(); //vyvod na ekran spiska
int current_element(int); //zdelat element s nomerom "int" tekushchim, vernetsa 0;
//Esli doidem do kontsa spiska,to vernetsa nomer poslednego elementa,kotoryi i budet tekushchim
int next_element(); //sdelat tekushchim sledujushchiy element tekuschuego
int previous_element(); //sdelat tekushchim predydushchiy element tekuschuego
int num_current(); //nomer v spiske tekushchego elementa
char* read_element(int &); //prochitat element s nomerom; Robe jogo tekushchim
char* read_element(); //prochitat tekushchiy element
void add_element(char*, int &);//dobavit element na nomer "int"; Robe novyi element tekushchim
void add_after(char*); //dobavit element posle tekushchego; Robe novyi element tekushchim
void add_before(char*); //dobavit element do tekushchego; Robe novyi element tekushchim
void del_element(); //udalit tekushchiy element; Robe sleduushchiy element tekushchim
void del_element(int &); //udalit element z nomerom "int"; Robe sleduushchiy element tekushchim
int fput_list(char*); //zapisat spisok v fail s imenem char*
int fget_list(char*); //vostanovit spisok iz faila s imenem char*
int num_list(); //kol-vo zvenjev u spiska
};
#endif
#ifndef list__h
#define list__h
#include "list.h"
#include <iostream.h>
list::list()
{
current=last=first=NULL;
};
void list::add_after(char* s)
{
if (current==NULL)
{
current=new element[1];
current->info=new char[strlen(s)+1];
strcpy(current->info,s);
current->up=current->down=NULL;
first=last=current;
return;
};
if (current==last)
{
last=new element[1];
last->info=new char[strlen(s)+1];
strcpy(last->info,s);
last->down=NULL;
last->up=current;
current->down=last;
current=last;
return;
};
//put in buffer adress down
last->down=current->down;
current->down=new element[1];
current->down->up=current;
current=current->down;
current->down=last->down;
//clear buffer
last->down->up=current;
last->down=NULL;
current->info=new char[strlen(s)+1];
strcpy(current->info,s);
return;
};
void list::add_before(char* s)
{
if (current==NULL)
{
add_after(s);
return;
};
if (current==first)
{
first=new element[1];
first->up=NULL;
first->down=current;
current=current->up=first;
first->info=new char[strlen(s)+1];
strcpy(first->info,s);
return;
};
first->up=current->up;
current->up=new element[1];
current->up->down=current;
current=current->up;
current->up=first->up;
first->up->down=current;
first->up=NULL;
current->info=new char[strlen(s)+1];
strcpy(current->info,s);
return;
};
void list::add_element(char* s, int &k)
{
int i;
i=current_element(k);
if ((i<k)&&(i!=0))
{
cout<<"V spiske vsego "<<i<<" elmentov. Po etomu vmesto "<<k<<" nomera, functsia dobavit info elementa na "<<i+1<<"-e mesto(poslednee v spiske)!!!\n";
k=i+1;
add_after(s);
};
if(i==0)
add_before(s);
return;
};
void list::del_element()
{
if (first==NULL)
{
cout<<"Nemogu udalit element so spiska. Spisok pust.\n";
return;
};
if (current==first)
{
if (current==last)
{first=last=NULL;}
else
{
first=current->down;
first->up=NULL;
};
delete[]current->info;
delete[]current;
current=first;
return;
};
if (current==last)
{
last=current->up;
last->down=NULL;
delete[]current->info;
delete[]current;
current=last;
return;
};
last->down=current->down;
current->up->down=current->down;
current->down->up=current->up;
delete[]current->info;
delete[]current;
current=last->down;
last->down=NULL;
return;
};
void list::del_element(int &k)
{
int i=current_element(k);
if ((i<k)&&(i!=0))
{
cout<<"V spiske vsego "<<i<<" elmentov. Po etomu vmesto "<<k<<" elementa, functsia udalit "<<i<<" element!!!\n";
k=i;
};
del_element();
return;
};
list::~list()
{
del_list();
};
void list::del_list()
{
while (last!=first)
{
current=last;
delete [] last->info;
last=last->up;
delete [] current;
};
if (first) delete [] first->info;
delete[]first;
current=first=last=NULL;
return;
};
//current ostaetsa netronutym
int list::num_list()
{
if(first==NULL) return 0;
int i(1);
element* temp=first->down;
while (temp!=NULL)
{
i++;
temp=temp->down;
};
return i;
};
//if OK return 0, esle return i (number current element)
int list::current_element(int k)
{
if (first==NULL)
{
cout<<"V spiske 0 elementov.\n";
return 0;
};
int i(1);
current=first;
if(i==k) return 0;
while (current->down)
{
current=current->down;
if (++i==k) return 0;
};
return i;
};
//Esli sled. element sdelalsa tekuschim return 1, else 0
int list::next_element()
{
if (current->down)
{
current=current->down;
return 1;
};
return 0;
};
//Esli pred. element sdelalsa tekuschim return 1, else 0
int list::previous_element()
{
if (current->up)
{
current=current->up;
return 1;
};
return 0;
};
int list::num_current()
{
if(current==NULL)return 0;
int i(1);
element* temp=current;
while (temp->up!=NULL)
{
i++;
temp=temp->up;
};
return i;
};
char* list::read_element()
{
return current->info;
};
char* list::read_element(int &k)
{
int i;
i=current_element(k);
if ((i<k)&&(i!=0))
{
cout<<"V spiske vsego "<<i<<" elmentov. Po etomu vmesto "<<k<<" elementa, functsia vozvrashchaet "<<i<<" element!!!\n";
k=i;
};
return current->info;
};
void list::init_list(int k, char* str)
{
if (k==0) return;
int f(2);
char* s;
s=new char[strlen(str)+7];
if (first!=NULL)
{
cout<<"Spisok ne pust!!!\n";
cout<<"Chto delat?(0/1/2)\n";
cout<<" 0)Otmenit initsializatsiu;\n";
cout<<" 1)Dopisat fonarnuu infomatsiu v konets spiska;\n";
cout<<" 2)Zamenit spisok novoi fonarnoi informatsyei.\n";
cin>>f;
};
if(f==0) return;
if(f==1) current=last;
if(f==2)
{
del_list();
first=new element[1];
first->info=new char[strlen(str)+3];
sprintf(first->info,"%s 1",str);
first->up=first->down=NULL;
current=last=first;
};
for (int j=f; j<=k; j++)
{
sprintf(s,"%s %d",str,j);
add_after(s);
};
return;
};
void list::print_list()
{
cout<<"Vmestimoe spiska:\n";
element* temp=first;
if (first==NULL)
{
cout<<"Spisok pust!!!\n";
return;
};
do
{
cout<<"| "<<temp->info<<" |";
temp=temp->down;
}
while (temp);
cout<<"\n";
return;
};
int list::fput_list(char* s)
{
FILE* f;
if ((f=fopen(s,"w+"))==NULL)
{
cout << "Can not open file "<<s<<"\n";
return 0;
};
if (!first) fclose(f);
element* temp=first;
do
{
fputs(temp->info,f);
fputs("\n",f);
temp=temp->down;
}
while (temp);
fclose(f);
return 1;
};
int list::fget_list(char* s)
{
int ff=2;
if (first!=NULL)
{
cout<<"Spisok ne pust!!!\nChto delat?(0/1/2)\n 0)Otmenit vostanovlenie iz faila;\n";
cout<<" 1)Vostanovit infomatsiu iz faila v konets spiska;\n";
cout<<" 2)Zamenit spisok informatsyei iz faila.\n";
cin>>ff;
};
if(!ff) return ff;
FILE* f;
if ((f=fopen(s,"r"))==NULL)
{
cout<<"Can not open file "<<s<<"\n";
return 0;
};
char str[255];
if(ff==1)
current=last;
char *sss;
if(ff==2)
del_list();
while (fgets(str,256,f))
{
sss=new char[strlen(str)];
int j=0;
while(str[j]!='\n')
sss[j]=str[j++];
sss[j]='\0';
add_after(sss);
delete [] sss;
};
fclose(f);
return ff;
};
#endif
#include "list_.h"
void main()
{
int n=16;
cout<<"Rozhdenie spiska...\n";
list s;
char a[255];
strcpy(a,"Seha");
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list();
cout<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();
cout<<"Skol'ko proinitsializirovat' elementov spiska?\nn=";
cin>>n;
cout<<"Initsialitsia spiska...\n";
s.init_list(n,a);
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list();
cout<<"\nTekuschiy element spiska: ";
cout<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();//clear iostream
getchar();
cout<<"Kakoi element v spiske sdelat' tekeschim?\nn=";
cin>>n;
s.current_element(n);
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Skol'ko elementov dobavit'?\n";
cin>>n;
getchar();//clear iostream
for (int i=0; i<n; i++)
{
cout<<"Vvedite stroku dlja dobavlenija v spisok\n";
gets(a);
cout<<"Dobavlenie posle tekuschego...\n";
s.add_after(a);
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();
};
cout<<"Delaem tekuschim sledujushiy element...\n";
s.next_element();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();
cout<<"Skol'ko eschje elementov spiska nuzhno dobavit'?\n";
cin>>n;
getchar();//clear iostream
for (int i=0; i<n; i++)
{
cout<<"Vvedite stroku dlja dobavlenija v spisok\n";
gets(a);
cout<<"Dobavlenie do tekuschego...\n";
s.add_before(a);
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();
};
cout<<"Skol'ko eschje elementov spiska nuzhno dobavit'?\n";
cin>>n;
getchar();//clear iostream
for (int k,i=0; i<n; i++)
{
cout<<"Vvedite stroku dlja dobavlenija v spisok\n";
gets(a);
cout<<"Vvedite nomer elementa, na kakoe mesto nuzhno dobavit' novyi element\n";
cin>>k;
cout<<"Dobavlenie "<<k<<"-togo elementa...\n";
s.add_element(a,k);
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();//clear iostream
getchar();
};
cout<<"Kakoi element v spiske sdelat' tekeschim?\nn=";
cin>>n;
s.current_element(n);
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Skol'ko elementov udalit'?\n";
cin>>n;
getchar();//clear iostream
for (int i=0; i<n; i++)
{
cout<<"Udalenie tekuschego...\n";
s.del_element();
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();
};
cout<<"Skol'ko eschje elementov spiska nuzhno udalit?\n";
cin>>n;
getchar();//clear iostream
for (int k,i=0; i<n; i++)
{
cout<<"Vvedite nomer elementa, kotoryi nuzhno udalit'\n";
cin>>k;
cout<<"Udalenie "<<k<<"-togo elementa...\n";
s.del_element(k);
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();//clear iostream
getchar();
};
cout<<"Zapis' spiska v fail...\n";
s.fput_list("Seha.lsm");
cout<<"Udalenie spiska...\n";
s.del_list();
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();
cout<<"Vostanovlenie spiska...\n";
s.fget_list("Seha.lsm");
s.print_list();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();
cout<<"Delaem tekuschim predyduschiy element...\n";
s.previous_element();
cout<<"\nVsego elementov v spiske: "<<s.num_list()<<"\nTekuschiy element spiska: "<<s.num_current()<<'\n';
cout<<"Press <Enter> for go on...\n";
getchar();
cout<<"Press <Enter> for exit...";
getchar();
};
Ðåçóëüòàò:
D:\Studies\Labs\Programing\Labs\Cpp\Individ_6\ind2>ind2
Rozhdenie spiska...
Vmestimoe spiska:
Spisok pust!!!
Vsego elementov v spiske: 0
Tekuschiy element spiska: 0
Press <Enter> for go on...
Skol'ko proinitsializirovat' elementov spiska?
n=9
Initsialitsia spiska...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 9
Tekuschiy element spiska: 9
Press <Enter> for go on...
Kakoi element v spiske sdelat' tekeschim?
n=6
Vsego elementov v spiske: 9
Tekuschiy element spiska: 6
Skol'ko elementov dobavit'?
3
Vvedite stroku dlja dobavlenija v spisok
Sveta 1
Dobavlenie posle tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Seha 7 || Seha 8
|| Seha 9 |
Vsego elementov v spiske: 10
Tekuschiy element spiska: 7
Press <Enter> for go on...
Vvedite stroku dlja dobavlenija v spisok
Sveta 2
Dobavlenie posle tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Seha 7
|| Seha 8 || Seha 9 |
Vsego elementov v spiske: 11
Tekuschiy element spiska: 8
Press <Enter> for go on...
Vvedite stroku dlja dobavlenija v spisok
Sveta 3
Dobavlenie posle tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Sveta
3 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 12
Tekuschiy element spiska: 9
Press <Enter> for go on...
Delaem tekuschim sledujushiy element...
Vsego elementov v spiske: 12
Tekuschiy element spiska: 10
Press <Enter> for go on...
Skol'ko eschje elementov spiska nuzhno dobavit'?
3
Vvedite stroku dlja dobavlenija v spisok
Svitlana 1
Dobavlenie do tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Sveta
3 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 13
Tekuschiy element spiska: 10
Press <Enter> for go on...
Vvedite stroku dlja dobavlenija v spisok
Svitlana 2
Dobavlenie do tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Sveta
3 || Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 14
Tekuschiy element spiska: 10
Press <Enter> for go on...
Vvedite stroku dlja dobavlenija v spisok
Svitlana 3
Dobavlenie do tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Sveta
3 || Svitlana 3 || Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 15
Tekuschiy element spiska: 10
Press <Enter> for go on...
Skol'ko eschje elementov spiska nuzhno dobavit'?
3
Vvedite stroku dlja dobavlenija v spisok
I
Vvedite nomer elementa, na kakoe mesto nuzhno dobavit' novyi element
10
Dobavlenie 10-togo elementa...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Sveta
3 || I || Svitlana 3 || Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 16
Tekuschiy element spiska: 10
Press <Enter> for go on...
Vvedite stroku dlja dobavlenija v spisok
like
Vvedite nomer elementa, na kakoe mesto nuzhno dobavit' novyi element
11
Dobavlenie 11-togo elementa...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Sveta
3 || I || like || Svitlana 3 || Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 17
Tekuschiy element spiska: 11
Press <Enter> for go on...
Vvedite stroku dlja dobavlenija v spisok
you!!!
Vvedite nomer elementa, na kakoe mesto nuzhno dobavit' novyi element
12
Dobavlenie 12-togo elementa...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 4 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Sveta
3 || I || like || you!!! || Svitlana 3 || Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 ||
Seha 9 |
Vsego elementov v spiske: 18
Tekuschiy element spiska: 12
Press <Enter> for go on...
Kakoi element v spiske sdelat' tekeschim?
n=4
Vsego elementov v spiske: 18
Tekuschiy element spiska: 4
Skol'ko elementov udalit'?
3
Udalenie tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 5 || Seha 6 || Sveta 1 || Sveta 2 || Sveta 3 || I ||
like || you!!! || Svitlana 3 || Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 17
Tekuschiy element spiska: 4
Press <Enter> for go on...
Udalenie tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Seha 6 || Sveta 1 || Sveta 2 || Sveta 3 || I || like || yo
u!!! || Svitlana 3 || Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 16
Tekuschiy element spiska: 4
Press <Enter> for go on...
Udalenie tekuschego...
Vmestimoe spiska:
| Seha 1 || Seha 2 || Seha 3 || Sveta 1 || Sveta 2 || Sveta 3 || I || like || you!!! || Sv
itlana 3 || Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 15
Tekuschiy element spiska: 4
Press <Enter> for go on...
Skol'ko eschje elementov spiska nuzhno udalit?
3
Vvedite nomer elementa, kotoryi nuzhno udalit'
2
Udalenie 2-togo elementa...
Vmestimoe spiska:
| Seha 1 || Seha 3 || Sveta 1 || Sveta 2 || Sveta 3 || I || like || you!!! || Svitlana 3 |
| Svitlana 2 || Svitlana 1 || Seha 7 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 14
Tekuschiy element spiska: 2
Press <Enter> for go on...
Vvedite nomer elementa, kotoryi nuzhno udalit'
12
Udalenie 12-togo elementa...
Vmestimoe spiska:
| Seha 1 || Seha 3 || Sveta 1 || Sveta 2 || Sveta 3 || I || like || you!!! || Svitlana 3 |
| Svitlana 2 || Svitlana 1 || Seha 8 || Seha 9 |
Vsego elementov v spiske: 13
Tekuschiy element spiska: 12
Press <Enter> for go on...
Vvedite nomer elementa, kotoryi nuzhno udalit'
12
Udalenie 12-togo elementa...
Vmestimoe spiska:
| Seha 1 || Seha 3 || Sveta 1 || Sveta 2 || Sveta 3 || I || like || you!!! || Svitlana 3 |
| Svitlana 2 || Svitlana 1 || Seha 9 |
Vsego elementov v spiske: 12
Tekuschiy element spiska: 12
Press <Enter> for go on...
Zapis' spiska v fail...
Udalenie spiska...
Vmestimoe spiska:
Spisok pust!!!
Vsego elementov v spiske: 0
Tekuschiy element spiska: 0
Press <Enter> for go on...
Vostanovlenie spiska...
Vmestimoe spiska:
| Seha 1 || Seha 3 || Sveta 1 || Sveta 2 || Sveta 3 || I || like || you!!! || Svitlana 3 |
| Svitlana 2 || Svitlana 1 || Seha 9 |
Vsego elementov v spiske: 12
Tekuschiy element spiska: 12
Press <Enter> for go on...
Delaem tekuschim predyduschiy element...
Vsego elementov v spiske: 12
Tekuschiy element spiska: 11
Press <Enter> for go on...
Press <Enter> for exit...
D:\Studies\Labs\Programing\Labs\Cpp\Individ_6\ind2>
Seha.lsm:
Seha 1
Seha 3
Sveta 1
Sveta 2
Sveta 3
I
like
you!!!
Svitlana 3
Svitlana 2
Svitlana 1
Seha 9
̳í³ñòåðñòâî îñâ³òè ³ íàóêè Óêðà¿íè Çàïîð³çüêèé íàö³îíàëüíèé óí³âåðñèòåò Êàôåäðà ³íôîðìàö³éíèõ òåõíîëîã³é ²íäèâ³äóàëüíà ðîáîòà Ç òåìè: «Ñ++. Êëàñè ³ îá’ºêòè» Âèêîíàâ: ñòóä. 2 êóðñó ìàòåì.
Copyright (c) 2024 Stud-Baza.ru Ðåôåðàòû, êîíòðîëüíûå, êóðñîâûå, äèïëîìíûå ðàáîòû.