|
|
ملتقى البرامج والانترنات والجرافيكس كل ما يختص بالكمبيوتر والانترنات من برامج ومعلومات وخدمات مجانية |
|
أدوات الموضوع | انواع عرض الموضوع |
#21
|
|||
|
|||
رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة
****** 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. Provide for class set that you have developed member functions to implement the following operations on sets using appropriate member functions: a) Determine the union of two sets and store the result in a third set; b) Determine the intersection of two sets and store the result in a third set; c) To test if a given set is the empty set; d) To test if one set is included in another set. Hint: The class should have data members an array of integers of a large size (for ex 20) and N= number of elements in the set. As you first create the set, N=0 (set by the constructor) The add function should add one element to the set. and not add two sets. void set::add(set &S, int x) will make x an element of the set S. for example, if S1 is still the empty set, and we call function add to add element 2 to S1, then S1 becomes: S1 = {2}, N=1. To add element 3: S1={2,3}, N=2 To remove element 2, S1={3}, N=1 therefore to remove an element, in the implementation of that function, we search the array to see if that element exists, and then if found, you have to slide the remaining elements back one position (i.e. no empty spots should exist in the array.) A utility function is a member function that can return a set. But you don't need the add function to return a set. Whereas the union and intersection functions may return the resulting set. If you really need a function (get or set) you can add it and justify its need in the comments.
__________________
بالصبر تبلغ ما ترجوه من أمل *** فاصبر فلا ضيق إلا بعده فرج |
#22
|
||||
|
||||
رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة
سؤال وردني عبر الخاص :
س1: أكتب برنامجاً بلغة فيجول بيسك لحساب مجموع الأرقام: ر=1تربيع+2تربيع...+100تربيع الإجابة sum = 1^2 + 2^2 +..... + 100^2 حيث ^ تعني ( أس ) sum : يمثل المجموع i: نسميه عداد هذه عبارة عن تعريفات للمتغيرات sum و i Dim sum As Double Dim i As Integer For i = 1 To 100 sum = sum + i ^ 2 Next i الجملة التالية تستخدم لإظهار المجموع بنافذة مستقلة MsgBox sum
__________________
عَنْ عَبْدِ اللَّهِ بْنِ مَسْعُودٍ رَضِيَ اللَّهُ تَعَالَى عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: لَا يَدْخُلُ الْجَنَّةَ مَنْ كَانَ فِي قَلْبِهِ مِثْقَالُ ذَرَّةٍ مِنْ كِبْرٍ أَخْرَجَهُ مُسْلِمٌ
|
#23
|
||||
|
||||
رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة
سؤال آخر :
س2: في الجمل الشرطية النوع التالت if_Then_Else_End If ممكن في أي حالة نستخدمه لأنو موجود عنا بالكتاب لكن بدون أمثله الإجابة تعتبر جمله If من الجمل الشرطيه نظرا لوجود شرط في صياغتها ويتم اختبار تحقق هذا الشرط (اي ناتج الشرط اما صواب True او خطأ False) وفي حاله تحققه (اي ناتج الشرط صواب True) تنفذ الاوامر التي تلي كلمه Then اما في حاله عدم تحققه (اي ناتج الشرط خطأ False ) تنفذ الاورامر التي تلي كلمه Else وصيغتها كالتالي :- If Condition Then .................... Codes ..................... Else ..................... Codes1 ...................... End If حيث Condition هي الشرط Codes هي الاوامر التي تنفذ اذا تحقق الشرط او نتيجه الشرط صواب True Codes1 هي الاوامر التي تنفذ اذا لم يتحقق الشرط او نتيجه الشرط خطأ False مثال: مدرس يحتاج لكتابة برنامج يقوم بطباعة ناجح " pass " إذا كانت علامة الطالب " mark " أكبر من أو يساوي 50 ويطبع راسب " Fail " إذا كانت علامة الطالب أقل من 50. طبعا في هذا السؤال يظهر لنا وجود شرط وهو " اذا كانت العلامة أكبر من أو يساوي 50 " وبناء عليه سنستخدم الجملة الشرطية If...........Then.........Else. Dim mark As Integer هنا سنعطي للعلامة قيمة 52 وبذلك سيطبع البرنامج Pass mark = 52اذا كانت العلامة اكبر من او يساوي 50 اطبع ناجح If mark >= 50 Then Print "Pass" وإلا اطبع راسب Else Print "Fail" End If
__________________
عَنْ عَبْدِ اللَّهِ بْنِ مَسْعُودٍ رَضِيَ اللَّهُ تَعَالَى عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: لَا يَدْخُلُ الْجَنَّةَ مَنْ كَانَ فِي قَلْبِهِ مِثْقَالُ ذَرَّةٍ مِنْ كِبْرٍ أَخْرَجَهُ مُسْلِمٌ
|
#24
|
||||
|
||||
رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة
[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"; }
__________________
عَنْ عَبْدِ اللَّهِ بْنِ مَسْعُودٍ رَضِيَ اللَّهُ تَعَالَى عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: لَا يَدْخُلُ الْجَنَّةَ مَنْ كَانَ فِي قَلْبِهِ مِثْقَالُ ذَرَّةٍ مِنْ كِبْرٍ أَخْرَجَهُ مُسْلِمٌ
|
#25
|
|||
|
|||
رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة
[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 ----------------------------------------- Brother Ahmed12 first of all thx for ur help but i would like from u to look at this solution: #include <iostream> using namespace std; class set { private: int elements [20]; int N; public: set (); void add (int); // add elements into the set void remove ( int); // remove elements from the set void printSet (); // print the elements of the set bool isEmptySet (); // check if set is empty or not; if empty return true set Union (set &); // perform a union between two sets set intersection (set &); // perform an intersection between two sets bool testIfSubset (set & ); // check if first set is subset in the second set }; set::set () { N = 0; // size of the set for (int i =0; i<=19; i++) elements[i] = 0; } void set::add(int e) { // check if the element fits in the set; i.e. if the set is full or not if (N == 20) // means that the set is full cout <<"The set is full"<<endl; else // the set is not full { bool found = false; // element not found in set for (int i = 0; i < N; i++) { if (e == elements[i]){ found = true; break;} } if (found) cout <<"element found in the set"; else { elements[N] = e; N++; // update the size of the set cout <<"Element added"<<endl; } } } void set::remove(int e) { if (!isEmptySet ()) // set is not empty { // search for the position of the element int position = -1; for (int i = 0; i < N; i++) { if (elements[i] == e) { position = i; break; } } if (position != -1) // element found in the set at index position { elements[position]=elements[N-1]; N--; // update the size of the set cout <<"element removed"<<endl; } else cout <<e<<" is not an element in the set"<<endl; } else cout <<"The set is empty; there is no elements found till yet"<<endl; } void set::printSet() { if (isEmptySet ()) cout <<"Set is empty"<<endl; else { cout <<"Elements are:"<<endl; for (int i = 0; i < N; i++) cout <<elements [i]<<" "; } cout <<endl; } bool set::isEmptySet() { return N == 0; } set set::Union(set & s1) { set resultSet; if (N == 0 && s1.N != 0) // if first set is empty and the second is not for (int i = 0; i < s1.N ; i++) resultSet.add(s1.elements[i]); else if (N != 0 && s1.N == 0) // if second set is empty and the first is not for (int i = 0; i < N; i++) resultSet.add(elements[i]); else if (N != 0 && s1.N != 0) // if two sets are not empty { // add elements of first set into result set for (int i = 0; i < N; i++) resultSet.add(elements[i]); // check if there exists elements found in the second set that can be added to the result set for (int i = 0; i < s1.N; i++) { resultSet.add(s1.elements[i]); } } else // if two sets are empty cout <<"Union between to (phi) sets is (phi)" <<endl; return resultSet; } set set::intersection(set & s1) { set resultSet; if (N != 0 && s1.N != 0) // if first set is empty and the second is not // check if there exists elements found in the second set that can be added to the result set for (int i = 0; i < N; i++) { bool found = false; // indicates that element is not found in the second set for (int j = 0; j < s1.N; j++) { if (elements[i] == s1.elements[j]) { found = true; // element in first set is found in the second set break; } } if (found) resultSet.add(elements[i]); } } else // if two sets are empty cout <<"Intersection between the sets is impossible" <<endl; return resultSet; } bool set::testIfSubset (set & s1) { Set rs = (*this).intersection(s1); if (rs == *this) return true; else return false; } void main () { // --- testing the class --- // int n; set s1; // add to set cout <<"Enter a number to add to set (-5 to end): "; cin >> n; while (n != -5) { s1.add(n); cout <<endl; s1.printSet(); cout <<"Enter a number to add to set (-5 to end): "; cin >> n; } // remove from set; system("cls"); s1.printSet(); cout <<"Enter a number to remove from set (-5 to end): "; cin >> n; while (n != -5) { s1.remove(n); cout <<endl; s1.printSet(); cout <<"Enter a number to remove from set (-5 to end): "; cin >> n; } system("cls"); // testing union, intersection and subset cout <<"Elements of set 1 are"<<endl; s1.printSet(); set s2; for (int i = 1; i <= 10; i++) s2.add(i * 2 - 3); cout <<"Elements of set 2 are"<<endl; s2.printSet(); set r1, r2; r1 = s1.Union(s2); r1.printSet(); r2 = s1.intersection(s2); r2.printSet(); if (s1.testIfSubset(s2)) cout <<"s1 is subset of s2"<<endl; else cout <<"s1 is not subset of s2"<<endl; }
__________________
بالصبر تبلغ ما ترجوه من أمل *** فاصبر فلا ضيق إلا بعده فرج |
#26
|
||||
|
||||
رد: أطلب أي برنامج أو أي مساعدة .. أنا مستعد
السلام عليكم
ارجو ان تساعدني اريد طريقة الاشتغال ب turbo pascal
__________________
|
#27
|
||||
|
||||
رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة
السلام عليكم و رحمة الله و بركاته
أعتقد ان الموضوع سيكون فاتحة خير على مبرمجي الشفاء عندي سؤال للأخوة :: هل أنجز احدكم تطيبقا باستعمال الفريمورك كيوتي ؟
__________________
أخي الكريم أسامة ,,, دااائما سامي يذكرني بأن أوصل سلامه لك وللجميع ,, |
#28
|
||||
|
||||
رد: أطلب أي برنامج أو أي مساعدة .. أنا مستعد
اقتباس:
السلام عليكم ورحمة الله وبركاته ،،،، بداية أعتذر كثيرا على التأخر ، إليك برنامج لغة باسكال من هنا :
__________________
عَنْ عَبْدِ اللَّهِ بْنِ مَسْعُودٍ رَضِيَ اللَّهُ تَعَالَى عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: لَا يَدْخُلُ الْجَنَّةَ مَنْ كَانَ فِي قَلْبِهِ مِثْقَالُ ذَرَّةٍ مِنْ كِبْرٍ أَخْرَجَهُ مُسْلِمٌ
|
#29
|
|||
|
|||
رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة
السلام عليكم ورحمة الله وبركاته في البداية اشكر لكم جهودكم الرائعه في طرح مثل هذه المواضيع الهادفه ..اسأل الله ان يجعلها في ميزان أعمالكم .. أرغب بعمل آله حاسبة عن طريق برنامج الفيجول بيسك .. هل من الممكن وضع درس يوضح طريقة عمل ذلك .. وشكرآ.. |
#30
|
|||
|
|||
رد: خدمات البرمجة ---- أطلب أي مساعدة في البرمجة
اقتباس:
أختي rose queen هل قصدت طريقة عمل عمليات للطرح والجمع وغيرها؟
__________________
بالصبر تبلغ ما ترجوه من أمل *** فاصبر فلا ضيق إلا بعده فرج |
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
|
|
Powered by vBulletin V3.8.5. Copyright © 2005 - 2013, By Ali Madkour |