|

JavaMatlabPhpHtmlJavaScriptCSSC#Delphi 1


Linux Unix AutoCAD 3D Access Orcad

: .

(. ). . :

1. .
2. .
3. .
4. , , ( ).

: , , .

 

. . . , . ( ), .

 

- MENU, . "" , "" . "" , , , , . " " . " " . .

 

1. Head.h

#ifndef TEXT_H
#define TEXT_H

#include <iostream.h>
#include <string.h>
#include <alloc.h>
#include <conio.h>
#include <stdlib.h>

 

struct FDat { //
char Name[20]; //
char r[4]; //
char d[10]; //
int size; //
char attr[4]; //
FDat *Next;
FDat *Previous;
};

FDat *Add(FDat *);
FDat *Del(FDat *, int &);
void Show (FDat *, FDat *);
void Find (FDat *);
void SortByName (FDat *);
void SortBySize (FDat *);
void FreeRam (FDat *);

#endif

 

2 PROGRAM

#include "head.h"

FDat *Add(FDat *posl)
{
cout << "+++ \n" ;

if (posl == NULL){
posl = new FDat;

cout << "Vvedite - Name, Racsherenie, Daty, Razmer and Attribut: \n";
cin >> posl->Name >> posl->r >> posl->d >> posl->size >> posl->attr;
posl->Next = NULL;
posl->Previous = NULL;
}
else {
posl->Next = new FDat;
posl->Next->Previous = posl;
posl = posl->Next;

cout << "Vvedite - Name, Racsherenie, Daty, Razmer and Attribut: \n";
cin >> posl->Name >> posl->r >> posl->d >> posl->size >> posl->attr;
posl->Next = NULL;
}

return posl;
}

///////////////////////////////////////////////////////////////////////

 

FDat *Del(FDat *begin, int &identif)
{
FDat *prom, *begin_new, *next;
int x = 0, j = 0, k = 0, y = 0;
char name[20];

cout << "Mi udalaem!!! \n";

cout <<"Vvedite NAME : ";
cin >> name;
begin_new = prom = next = begin;
while ( begin != NULL) {
for (int i = 0; i<strlen(name); i++)
if (name[i] == begin->Name[i]) j++;
if (j == strlen(name)) {
if (prom == begin) {
begin_new = begin->Next;
prom = begin->Next;
delete begin;
x = 1;
y = 1;
begin = prom;
}
else {
while ( k == 0) {
if (next->Next == begin){
if (next->Next->Next == NULL) {
k = 1;
x = 1;
delete begin;
next->Next = NULL;
begin = NULL;
identif = 1;
begin_new = next;
}
else {
prom = begin->Next;
delete begin;
x = 1;
k = 1;
y = 1;
next->Next = begin = prom;
}
}
next = next->Next;
}
}
}
if (y == 1) begin = NULL;
if (begin != NULL) begin = begin->Next;
j = 0;
}
if (x == 0)
cout << "NAME nety ... ";
getch();
return begin_new;

}

 

/////////////////////////////////////////////////////////////////////////

 

void Show (FDat *begin, FDat *posl)
{
int x;
cout << "Prosmotr spiska!!! \n";
cout <<"Vvivod snachala (press ... 0) ili s konca (press ... 1)???\n";
cin>>x;
cout <<"Name, Racsherenie, Data, Razmer and Attribut\n";
if (x == 0)
while ( begin != NULL) {
cout <<"\n"<< begin->Name <<"."<<begin->r <<" "<<begin->d <<" "
<< begin->size <<" byte "<<begin->attr <<" \n ";
begin = begin->Next;
}
else
while (posl != NULL) {
cout <<"\n"<< posl->Name <<"."<<posl->r <<" "<<posl->d <<" "
<< posl->size <<" byte "<<posl->attr <<" \n ";
posl = posl->Previous;
}
getch();
}

 

/////////////////////////////////////////////////////////////////////////

void Find (FDat *begin)
{
int x = 0, j = 0;
char name[20];
cout << "poisk!!! \n";
cout <<"Vvedite NAME : ";
cin >> name;
while ( begin != NULL) {
for (int i = 0; i<strlen(name); i++)
if (name[i] == begin->Name[i]) j++;

if (j == strlen(name)) {
cout <<"\n"<< begin->Name <<"."<<begin->r <<" "<<begin->d <<" "
<< begin->size <<" byte"<<begin->attr <<" \n ";
x = 1;
j = 0;
}

begin = begin->Next;
}
if (x == 0)
cout << "NAME nety ... ";
getch();

}

//////////////////////////////////////////////////////////////////

void SortByName (FDat *begin )
{
char Name2[20]; //
char r2[4]; //
char d2[10]; //
int size2; //
char attr2[4]; //
FDat *Next2;
FDat *Previous2;
FDat *Work;
int k = 1, _k = 1;

Work = begin;

while (k == 1){
begin = Work;
while ( begin->Next != NULL) {
if (begin->Name < begin->Next->Name) {
strcpy (Name2 , begin->Name);
strcpy (r2 , begin->r);
strcpy (d2 , begin->d);
size2 = begin->size;
strcpy (attr2 , begin->attr);

strcpy (begin->Name, begin->Next->Name);
strcpy (begin->r, begin->Next->r);
strcpy (begin->d, begin->Next->d );
begin->size = begin->Next->size;
strcpy (begin->attr, begin->Next->attr);

strcpy (begin->Next->Name, Name2);
strcpy (begin->Next->r, r2);
strcpy (begin->Next->d, d2);
begin->Next->size = size2;
strcpy (begin->Next->attr, attr2);

_k = 0;
}

begin = begin->Next;
}
if (_k == 1)
k = 0;
_k = 1;
}

cout <<"Sortirovka osyshestvlena!!!";
getch();

}

///////////////////////////////////////////////////////////////////

void SortBySize (FDat *begin )
{
char Name2[20]; //
char r2[4]; //
char d2[10]; //
int size2; //
char attr2[4]; //
FDat *Next2;
FDat *Previous2;
FDat *Work;
int k = 1, _k;

Work = begin;

while (k == 1){
begin = Work;
_k = 1;
while ( begin->Next != NULL) {
if (begin->size > begin->Next->size) {
strcpy (Name2 , begin->Name);
strcpy (r2 , begin->r);
strcpy (d2 , begin->d);
size2 = begin->size;
strcpy (attr2 , begin->attr);

strcpy (begin->Name, begin->Next->Name);
strcpy (begin->r, begin->Next->r);
strcpy (begin->d, begin->Next->d );
begin->size = begin->Next->size;
strcpy (begin->attr, begin->Next->attr);

strcpy (begin->Next->Name, Name2);
strcpy (begin->Next->r, r2);
strcpy (begin->Next->d, d2);
begin->Next->size = size2;
strcpy (begin->Next->attr, attr2);

_k = 0;
}

begin = begin->Next;
}
if (_k == 1)
k = 0;
}
cout <<"Sortirovka osyshestvlena!!!";
getch();

}

///////////////////////////////////////////////////////////////////

 

void FreeRam (FDat *begin)
{
FDat *prom;
prom = begin;
while ( prom != NULL) {
begin = begin->Next;
delete prom;
prom = begin;
}
}

 

///////////////////////////////////////////////////////////////////

 

int main()
{
long int mem;
FDat *Begin = NULL, *Posl = NULL, *Dopol;
int ch, iden = 0; // {. }

mem = farcoreleft(); // { . }
cout <<"Memory - "<<mem<<"\n";
do {
cout<<" <1> - DOBAVIT ZAPIS \n"
<<" <2> - UDALIT ZAPIS \n"
<<" <3> - PROSMOTR SPISKA \n"
<<" <4> - POISK \n"
<<" <5> - Sort po Name \n"
<<" <6> - Sort po Size \n"
<<" <7> - EXIT \n";

cin>>ch; // { }

switch (ch) {
case 1 :
if (Begin == NULL) {
Begin = Add(Posl);
Posl = Begin;
}
else Posl = Add(Posl);
break;
case 2 :
Dopol = Del(Begin, iden);
if (iden == 0) Begin = Dopol;
else Posl = Dopol;
break;
case 3 :
Show(Begin, Posl);
break;
case 4 :
Find(Begin);
break;
case 5 :
SortByName (Begin);
break;
case 6 :
SortBySize (Begin);
break;
}
} while (ch != 7);

cout <<"\n Memory - " <<farcoreleft()<<"\n";

FreeRam(Begin); // { }
getch();

cout <<"\n Memory - " <<farcoreleft()<<"\n";
if (mem == farcoreleft()) cout <<"Pamat' ne poterana ... ";
else cout << "ERROR!!! Potera Memory!!!";

cout<<" Press key..."<<endl;
getch();

return 0;

}

 

: 12206





php mysql



C


 


? :

, ? Google !

 
 

© life-prog.ru .