الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[مخالف]مي يو هلب مي

مغلق
بدأه سجى الليل في 6 مايو 2012 · 1 رد · 262 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

اذ ممكن تساعدوني جزاكم الله الف خيرا وخيرااااااا

وبعد الخير جنات النعيم

عندي اسايمنت متعلق بlinked list بصراحة عجبني موضوع مطروح في منتداكم عن ها الموضوع

بس حاولت في الاسيمنت ولزاك يحتاجله شغل وتفكير وانا يا مسكينة ذو عقوى عقلية ضعيفة ^_^

هذا الكود مبدائيا

#include<iostream>

#include<fstream>

#include<string>

using namespace std;

//property structure

struct Property

{

string PropertyId;

int PropertyType;

int NumberOfRoom;

string PropertyLocation;

float PropertyPrice;

};

//node

struct Node

{

Property data;

Node * next;

};

typedef Node* node_ptr;

//protype

void FileToList(Node *& a);

void ListToFile(Node *a);

void AddToProperty(Node *& a);

void DeleteProperty(Node *& a,string userW);

int size=0;

//main

int main()

{

node_ptr q=NULL;

FileToList(q);

ListToFile(q);

AddToProperty(q);

string userW;

cout<<"Enter property id ? ";

cin>>userW;

DeleteProperty(q,userW);

return 0;

}//end of main

//read data

void FileToList(Node *& a)

{

//open file

ifstream input;

input.open("property.txt");

if(!input)

{

cout<<cout<<"Error opening file\n";

exit(1);

}

//read data

//first node

a= new Node[6];

input>>a->data.PropertyId>>a->data.PropertyType>>a->data.NumberOfRoom

>>a->data.PropertyPrice>>a->data.PropertyLocation;

cout<<a->data.PropertyId<<endl;

a->next=NULL;

//loop for complet read

node_ptr p,q=0;

p=a;

while(input)

{

p=p->next;

q= new Node[6];

input>>q->data.PropertyId>>q->data.PropertyType>>q->data.NumberOfRoom

>>q->data.PropertyPrice>>q->data.PropertyLocation;

cout<<q->data.PropertyId<<endl;

p=q;

size++;

}

//close file

input.close();

}

void ListToFile(Node *a)

{

//open file

ofstream output;

output.open("property.txt");

//

node_ptr p;

p=a;

while(p!=NULL)

{

output<<p->data.PropertyId<<" "<<p->data.PropertyType<<" "

<<p->data.NumberOfRoom<<" "<<p->data.PropertyPrice<<" "

<<p->data.PropertyLocation<<endl;

p=p->next;

}

}

void AddToProperty(Node *& a)

{

node_ptr p,q=0;

p=a;

do

{

p=p->next;

q=new Node[6];

cout<<endl<<"Enter property id : ";

cin>>q->data.PropertyId;

cout<<endl<<"Enter property type<0 for flat ,1 to house : ";

cin>>q->data.PropertyType;

cout<<endl<<"Enter property number of rooms : ";

cin>>q->data.NumberOfRoom;

cout<<endl<<"Enter property price OMR: ";

cin>>q->data.PropertyPrice;

cout<<endl<<"Enter property Location : ";

cin>>q->data.PropertyLocation;

q->next=NULL;

p=q;

}while(p->next!=NULL) ;

}

void DeleteProperty(Node *& q,string userW)

{

node_ptr d;

if(q->next!=NULL)

{

d=q->next;

d->next=q->next->next;

delete q;

q=d;

}

else

delete q;

}

Node *SearchProperty(Node *a ,string b)

{

node_ptr p,q;

p=a;

while(p->data.PropertyId!=b && p->next!=NULL)

{p=p->next;

if(p->next!=NULL)

q=p;

}

return q;

}

void updata(Node*&a)

{

node_ptr p;

p=a;

while(p->data.PropertyId!=s && p->next!=NULL)

p=p->next;

if(p->next!=NULL)

strcpy(p->data.,name);

}

الاسيمنت في المرفق

وشكراااا لكل من مررر على موضوعيA5.rar

#2

الأخ الكريم/الأخت الكريمة

السلام عليكم ورحمة الله وبركاته

مرحباً بكم في منتدى الفريق العربي للبرمجة

تأسف إدارة المنتدى لغلق الموضوع وذلك لمخالفته قوانين المشاركات .

قواعد طرح المشاركات

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

{username}

1

مدونتي: C++ Tips and Tricks

هذا الموضوع مغلق.

مواضيع مشابهة