عرض مشاركة واحدة
  #24  
قديم 23-03-2009, 04:00 PM
الصورة الرمزية ahmad12
ahmad12 ahmad12 غير متصل
*مشرف ملتقى البرامج*
 
تاريخ التسجيل: Jul 2008
مكان الإقامة: في أرض الله
الجنس :
المشاركات: 4,155
افتراضي رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة

[quote=zaynubya;671338]****** Oriented Programming


Write a program to carry out manipulation on sets. Create a class called set with two private members, the elements of the set and the size of the set. The elements should be an array of integers to hold an appropriate number of elements (e.g. 20). Provide a default constructor to initialize a newly defined set to be the empty set, the size of which should be zero. Provide also three utility functions to add, remove and to print elements of a set.

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

أختي الكريمة zaynubya لقد قمت ببرمجة هذه الجزئية من البرنامج وإن شاء الله تستفيدي منها ، إليك الكود المطلوب والباقي سأحاول برمجته في أسرع وقت ممكن :

First: Define the class "Set"

# include <iostream.h>

class Set {

public :
Set(){ N = 0; }
// Default constructor
void add( Set& S, int x);
void Remove( Set& S, int x);
void print( );

private:
int N;
int e[20];

} ;

Second: This is the function "add" written after main() function

void Set :: add( Set& S, int x )
{

S.e[ N ] = x;
N += 1;

}

Third: This is the function "Remove" written after main() function


void Set :: Remove( Set& S, int x )
{
int j = 0;
for (int i = 0; i < S.N; i++ )
if (( S.e[i] == x) || j)
{
S.e[i] = S.e[i + 1];
j = 1;
}
if ( j ) S.N -= 1;

}

Fourth: This is the function "print" written after main() function

void Set :: print ()
{
cout << " \n\nYour Set is : \n\n\tS = { ";
for (int i = 0; i < N -1 ; i++)
cout << e[i] << ", ";

if (N) cout << e[i] << " } \n\n";
else cout << " } \n\n";
}

__________________
عَنْ عَبْدِ اللَّهِ بْنِ مَسْعُودٍ رَضِيَ اللَّهُ تَعَالَى عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: لَا يَدْخُلُ الْجَنَّةَ مَنْ كَانَ فِي قَلْبِهِ مِثْقَالُ ذَرَّةٍ مِنْ كِبْرٍ أَخْرَجَهُ مُسْلِمٌ

رد مع اقتباس
 
[حجم الصفحة الأصلي: 16.05 كيلو بايت... الحجم بعد الضغط 15.42 كيلو بايت... تم توفير 0.63 كيلو بايت...بمعدل (3.95%)]