
Заключение
В данном курсовом проекте была спроектирована структура базы данных, предназначенной для функционирования автоматизированной информационной системы «Характеристики водоемов». Были получены навыки и умения проектирования подобной структуры базы данных.
Была разработана структура базы данных для информационной системы «Характеристики водоемов»
При использовании данной базы данных достигается хорошая автоматизация и простота работы со всеми данными.
Программа была протестирована, проверена на правильность выполнения операций: поиска, сортировки, ввода, удаления, вывода записей данных, редактирования, ввода новой БД с клавиатуры.
Меню программы доступно и понятно пользователю.
Список литературы
Павловская Т.А. С/С++. Программирование на языке высокого уровня – СПб.: Питер, 2006. – 461 с.: ил.
Павловская Т.А.,Щупак Ю.А. С/С++. Структурное программирование: Практикум – СПб.: Питер, 2002. – 240 с.: ил.
Введение в язык С++, Бьярн Страустрап, 1995 г., электронный учебник.
Подбельский В.В. Язык Си++: Учеб. Пособие.-5-е изд.-М.:Финансы и статистика, 2004.-56-с.
Приложение 1
Блок-схема функции main()
Блок-схема функции
inputstructfile()
Блок-схема функции outputstruct()
Блок-схема
функции addVodoem
()
Блок-схема
функции deleteVodoem()
Блок-схемы
функций
sort1() и sort2() :
Блок-схема функции redaktirovanie() :
Блок-схема функции input()
Б
лок-схема
функции
o
utputstructfile()
i=i+1
Блок-схема функции searchmesto()
Блок-схема функции searchploshad()
Листинг
программы:
#include<iostream.h>
#include<string.h>
#include<iomanip.h>
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>
struct Vodoem
{
char name[30];
char place[30];
char living[30];
char dirt[30];
double s;
};
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
class Tab
{
private:
Vodoem *pst;
int n;
public:
int i;
Tab(){n=0;pst=NULL;}
~Tab();
void inputstructfile();
void outputstruct();
void sort1();
void sort2();
void searchmesto();
void searchploshad();
void addVodoem();
void deleteVodoem();
void redaktirovanie();
void input();
};
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::inputstructfile()
{
ifstream fin;
char infile[20];
Vodoem t;
if(pst!=NULL){delete[] pst;n=0;pst=NULL;}
cout<<"please,enter
the name of file:";
cin>>infile;
fin.open(infile);
if(fin==NULL){cout<<"orry,this file can not be open";getch();exit(1);}
n=0;
do{
fin>>t.name>>t.place>>t.living>>t.dirt>>t.s;
n++;
}
while(fin.good());
n--;
fin.close();
pst=new Vodoem[n];
if(pst==NULL){cout<<"sorry,there is no enough dinamic memory";getch();
exit(1);}
fin.open(infile);
if(fin==NULL){cout<<"sorry,file can not be open";getch();exit(1);}
for(i=0;i<n;i++)
{
fin>>pst[i].name>>pst[i].place>>pst[i].living>>pst[i].dirt>>pst[i].s;
}
fin.close();
cout<<"file vveden!:)";getch();
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::outputstruct()
{ int i;
cout<<"\n\tData table:\n\n";
cout<<"---------------------------------------------------------"<<endl;
cout<<" #"<<setw(11)<<"Nazvanie"<<" "<<setw(9)<<"mesto "<<" "<<setw(11)<<"obitateli"<<" "<<setw(11)<<"zag-teli"<<" "<<setw(9)<<"plohad"<<endl;
cout<<"---------------------------------------------------------"<<endl;
for(i=0;i<n;i++)
cout<<setw(2)<<i+1<<" "<<setw(10)<<pst[i].name<<" "<<setw(9)<<pst[i].place<<" "<<setw(11)<<pst[i].living<<" "<<setw(11)<<pst[i].dirt<<" "<<setw(9)<<pst[i].s<<endl;
cout<<"---------------------------------------------------------"<<endl;
getch();
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void
Tab::sort1()
{
cout<<"sortirovka po mestoraspologeniu vodoema:";
Vodoem t;
for(i=0;i<n;i++)
for(int j=i+1;j<n;j++)
if(strcmp(pst[i].place,pst[j].place)>0)
{t=pst[i];pst[i]=pst[j];pst[j]=t;}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::sort2()
{
cout<<"sortirivka po ploshadi:";
Vodoem t;
for(i=0;i<n;i++)
for(int j=i+1;j<n;j++)
if((pst[i].s-pst[j].s)>0)
{t=pst[i];pst[i]=pst[j];pst[j]=t;}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::searchmesto()
{
cout<<"poisk po mestoraspologeniu:";
int d=0;
char imya[20];
cout<<"enter name:";
cin>>imya;
for(i=0;i<n;i++)
if(strcmp(imya,pst[i].name)==0)
{d=d++;}
if(d!=0)
{cout<<imya<<"\t"<<d<<endl;}
if(d==0){cout<<"there is no Vodoem with name"<<endl;
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::searchploshad()
{
int i,h;
cout<<"poisk po ploshadi:";
cout<<"enter ploshad':";
cin>>h;
for(i=0;i<n;i++)
if(pst[i].s<=h)
cout<<setw(2)<<i+1<<" "<<setw(10)<<pst[i].name<<" "<<setw(9)<<pst[i].place<<" "<<setw(11)<<pst[i].living<<" "<<setw(11)<<pst[i].dirt<<" "<<setw(9)<<pst[i].s<<endl;
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::addVodoem()
{
Vodoem t,*p;
cout<<"enter name:";
cin>>t.name;
cout<<"enter place:";
cin>>t.place;
cout<<"enter living:";
cin>>t.living;
cout<<"enter dirt:";
cin>>t.dirt;
do{
cout<<"\nEnter ploshad':";
cin>>t.s;
if(t.s<0){cout<<"\nError!Ploshad' can not be bellow zero!Please,try again.\n";}
}
while(t.s<0);
p=pst;
pst=new Vodoem[n+1];
if(pst==NULL){cout<<"sorry,there is no enough dinamic memory";getch();exit(1);}
for(i=0;i<n;i++)
pst[i]=p[i];
pst[n]=t;
n++;
delete[] p;
cout<<"zapis' dobavlena";
getch();
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::deleteVodoem()
{
Vodoem t;
cout<<"enter name:";
cin>>t.name;
cout<<"enter ploshad':";
cin>>t.s;
for(i=0;i<n;i++)
if(strcmp(t.name,pst[i].name)==0 && (t.s==pst[i].s))break;
if(i==n){cout<<t.name<<"not found \n";getch();exit(1);}
else{ for(int j=i+1;j<n;j++)
pst[j-1]=pst[j];
n--;
}
cout<<"zapis' ydalena";
getch();
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::redaktirovanie()
{
Vodoem x;
int i,j;
if(pst==NULL){cout<<"spisok pyst\n";getch();exit(1);}
cout<<"nomer redaktiryemou stroki:\n";
cin>>j;
cout<<"enter name:";
cin>>x.name;
cout<<"enter place:";
cin>>x.place;
cout<<"enter living:";
cin>>x.living;
cout<<"enter dirt:";
cin>>x.dirt;
cout<<"enter ploshad':";
cin>>x.s;
pst[j-1]=x;
cout<<"redaktirovanie zaverheno!"<<endl;
}
\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void Tab::input()
{
int i;
cout<<"enter kol-vo strok:"<<endl;
cin>>n;
cout<<"enter data table:"<<endl;
for(i=0;i<n;i++)
{ cout<<i+1<<".";
cout<<"name:";
cin>>pst[i].name;
cout<<"place:";
cin>>pst[i].place;
cout<<"living:";
cin>>pst[i].living;
cout<<"dirt:";
cin>>pst[i].dirt;
cout<<"ploshad':";
cin>>pst[i].s;
cout<<endl;
}
cout<<"data enterned!"<<endl<<endl;
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Tab::~Tab()
{if(pst!=NULL){delete[] pst;n=0;pst=NULL;}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void main()
{
Tab a;
int j,m,b;
while(1)
{
clrscr();
cout<<"\n1.Enter the data table from file\n";
cout<<"\n2.Enter the data on displey\n";
cout<<"\n3.Sorting the data table\n";
cout<<"\n4.Searching for...\n";
cout<<"\n5.Addition the line to the data table\n";
cout<<"\n6.Removal the line from the data table\n";
cout<<"\n7.redaktirovanie\n";
cout<<"\n8.enter new BD\n";
cout<<"\n9.Exit the programm\n\n";
cin>>j;
switch(j)
{
case 1:a.inputstructfile();break;
case 2:a.outputstruct();getch();break;
case 3:
{
int fl=0;
while(fl!=0)
clrscr();
cout<<"\n1.Sorting on type place\n";
cout<<"\n2.Sorting on ploshd'\n";
cin>>m;
switch(m)
{
case 1:a.sort1();a.outputstruct();a.inputstructfile();getch();break;
case 2:a.sort2();a.outputstruct();a.inputstructfile();getch();break;
case 3:fl=1;break;
default: cout<<"Error!Try again";break;
}
break;
}
case 4:
{
int fl1=0;
while(fl1!=0)
clrscr();
cout<<"\n1.Searching on type of name\n";
cout<<"\n2.searching on ploshad'";
cout<<"\n3.Exit to the main menu\n";
cin>>b;
switch(b)
{
case 1:a.searchmesto();getch();break;
case 2:a.searchploshad();getch();break;
case 3:fl1=1;break;
default: cout<<"Error!Try again";break;
}
break;
}
case 5:a.addVodoem();getch();break;
case 6:a.deleteVodoem();getch();break;
case 7:a.redaktirovanie();getch();break;
case 8:a.input();getch();break;
case 9:cout<<"Exit the programm.Thank you for using the programm!Good Luck!=)";getch();return;
default: cout<<"Error!Try again.";break;
}
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\