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

كيف تعمل Call من ال Main

مغلق
بدأه love_city في 26 أكتوبر 2007 · 0 رد · 324 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1
/* Implementation of UnsortedList ADT */
class UnsortedType {
public:
UnsortedType();
void MakeEmpty();
bool IsFull() const;
int LengthIs() const;
void RetrieveItem(ItemType& item, bool& found);
void InsertItem(ItemType item);
void DeleteItem(ItemType item);
void ResetList();
void GetNextItem(ItemType& item);
int CountGreater(ItemType someItem);
private:
int length;
ItemType info[MAX_ITEMS];
int currentPos;
};
UnsortedType::UnsortedType() {
length=0;
}
void UnsortedType::MakeEmpty(){
length=0;
}
bool UnsortedType::IsFull() const {
return (length ==MAX_ITEMS);
}
int UnsortedType::LengthIs() const {
return length;
}
void UnsortedType::RetrieveItem(ItemType& item, bool& found){
bool moreToSearch;
int location=0;
found = false;
moreToSearch = (location < length);
while (moreToSearch && !found)
{
switch (item.ComparedTo(info[location]))
{
case LESS:
case GREATER: location++;
moreToSearch = (location<length);
break;
case EQUAL : found = true;
item = info[location];
}
}
}
void UnsortedType::InsertItem(ItemType item)
{
info[length]= item;
length++;
}
void UnsortedType::DeleteItem(ItemType item)
{
int location =0;
while (item.ComparedTo(info[location]) != EQUAL)
location++;
info[location]= info[length -1];
length--;
}
void UnsortedType::ResetList()
{
currentPos = -1;
}
void UnsortedType::GetNextItem(ItemType& item)
{
currentPos++;
item = info[currentPos];
}
int UnsortedType::CountGreater(ItemType someItem)
{

	int count=0;
	bool mts;
	int loc=0;
	mts=(loc<length);
	while (mts)
	{
		switch (someItem.ComparedTo(info[loc]))
		{
		case LESS:
		case EQUAL: loc++;
		mts=(loc<length);
		break;
		case GREATER:
			count=count+1;
		}

	}return count;
}

#include <iostream.h>
/* Information provided by the user */
const int MAX_ITEMS = 50;
enum RelationType {LESS, GREATER, EQUAL};
class ItemType {
public:
ItemType();
RelationType ComparedTo(ItemType) const;
void Print() const;
void Initialize(int number);
private:
int value;
};
ItemType::ItemType()
{
value=0;
}
RelationType ItemType::ComparedTo(ItemType
otherItem) const
{
if (value < otherItem.value)
return LESS;
else if (value > otherItem.value)
return GREATER;
else return EQUAL;
}
void ItemType::Initialize(int number)
{
value = number;
}
void ItemType::Print() const
{
cout<<value<<" ";
}

السؤال هو في المين يعني رح أنزل المين ولكن الفانكشن يلي عم ناديها ما عم تشتغل بالطريقة المطلوبة وإليكم ال مين وشكراً

/********************************************/
/* Application using UnsortedList ADT */
/********************************************/
#include "ItemType.h"
#include "UnsortedList ADT.h"
void CreateList(UnsortedType&);
void PrintList(UnsortedType);
void GetData(ItemType&);
ItemType ListSum (UnsortedType list);
void main()
{
	ItemType item;
UnsortedType list;
cout<<"Enter integer values.."<<endl;
CreateList (list);
PrintList(list);
bool f;
cout<<" Enter an item "<<endl;
list.InsertItem(item);
GetData(item);
list.RetrieveItem(item,f);

cout<<endl;
}
void CreateList (UnsortedType& list) {
ItemType item;
char moreData='Y';
list.MakeEmpty();
while(moreData=='Y') {
GetData(item);
if(!list.IsFull())
list.InsertItem(item);

cout<<endl<<"More data?(y/n): ";
cin>>moreData;
moreData =(moreData=='y'?'Y':moreData);
}
}
void PrintList(UnsortedType list)
{
int length;
ItemType item;
list.ResetList();
length = list.LengthIs();
for( int counter = 1; counter <= length; counter++)
{
list.GetNextItem(item);
item.Print();
}
cout<<endl;
}


void GetData(ItemType& item)
{
int data;
cin>>data;
item.Initialize(data);
}

السؤال هنا

bool f;
cout<<" Enter an item "<<endl;
list.InsertItem(item);
GetData(item);
list.RetrieveItem(item,f);

الفانكشن يلي بآخر سطر مش عم تشتغل شغلها يعني لازم أحط رقم والفانكشن تعمل بحث إذا لاقيت الرقم بتحكي الموقع إذا لأ خلص ما بتحكي شي

وشكراً

تم تعديل هذه المشاركة بواسطة love_city في 26 أكتوبر 2007 في 23:04

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

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