PDA

View Full Version : Помощ по информатика...



pavkata213
12-02-2010, 19:43
Имам една задачка за домашно, но не мога да ги правя тези задачи и със голяма помощ успях да стигна до края на входа...поне според господина ми...та той иска да я продължа като ме пита:"Съществува ли имот с даден номер и ако съществува да се изведат данните му,ако не-да изпише, че няма? Ще се радвам ако ми отговорите тази вечер.Благодаря предварително ..ето до къде съм стигнал аз:



#include<iostream.h>
#include<fstream.h>
struct Propertie
{
int inv_number;
char type [20];
char town [20];
int price;
int quardature;
char street [20];
int discount;
};
int main ()
{
Propertie properties;
fstream file;
file.open("properties.txt",ios::in|ios::out);
int n;
cout<<"broy imoti:";
cin>>n;
for(int i=1;i<n;i++)
{
int inv_number=i;
cout<<"tip:";
cin>>properties.type;
cout<<"grad:";
cin>>properties.town;
cout<<"cena:";
cin>>properties.price;
cout<<"kvadratura:";
cin>>properties.quardature;
cout<<"ulica:";
cin>>properties.street;
cout<<"namalenie:";
cin>>properties.discount;
file<<properties.inv_number<<" ";
file<<properties.type<<" ";
file<<properties.town<<" ";
file<<properties.price<<" ";
file<<properties.quardature<<" ";
file<<properties.street<<" ";
file<<properties.discount<<" ";
file<<"\n";
}
file.seekg(0);
for(i=1;i<n;i++)
{
file>>properties.inv_number;
file>>properties.type;
file>>properties.town;
file>>properties.price;
file>>properties.quardature;
file>>properties.street;
file>>properties.discount;
cout<<"inventaren nomer:"<<properties.inv_number<<" ";
cout<<"tip:"<<properties.type<<" ";
cout<<"grad:"<<properties.town<<" ";
cout<<"cena:"<<properties.price<<" ";
cout<<"kvadratura:"<<properties.quardature<<" ";
cout<<"ulica:"<<properties.street<<" ";
cout<<"namalenie:"<<properties.discount<<" ";
cout<<endl<<endl;
}
file.close();
return 0;
}

Foreverbg
12-02-2010, 21:39
След като въведеш информацията за имотите, с които разполагаш не трябва ли да въведеш и имота, който търсиш? Търсенето може да стане с байнъри сърч, което е доста бързо или с два вложени фора.

pavkata213
12-02-2010, 22:21
ще се радвам да го напишеш , защото си нямам и на идея какво каза :Д мерси предварително