| الإهداءات |
|
|||||||
|
|
أدوات الموضوع | انواع عرض الموضوع |

|
|
#11 | ||||
|
قوة السمعة: 103
![]() |
السؤال تقلص لشو سبب الرن تايم ايرور بهاد الكود
#include <iostream> using namespace std ; class ArrayList { int size; public : int *list; ArrayList(); ArrayList(int ) ; void SetSize(int); int GetSize(); void ReadArray(); void PrintArray(); int PositiveCount(); void copyPositiveValues(ArrayList obj1); ~ArrayList(); }; ArrayList::ArrayList(){size=5;}; ArrayList::ArrayList(int n){size=n;} void ArrayList::SetSize(int S ){size=S;} int ArrayList::GetSize(){return 6 ;} void ArrayList::ReadArray(){ int num; for (int i=0 ; i<size ; i++) { cin >>num; list[i]= num ;} } void ArrayList::PrintArray(){ for (int i=0 ; i < size ; i++) cout <<list[i]<<" ";} int ArrayList::PositiveCount(){int Pcount=0 ; for(int i =0;i<size ; i++) { if (list[i] >= 0) Pcount++; } return Pcount; } void ArrayList::copyPositiveValues(Array List obj1) { obj1.list; for (int i=0; i<size ; i++) { if (list[i]>=0) cout <<list[i] <<" " ; } cout <<endl; } ArrayList::~ArrayList(){ } void main () { ArrayList list; cout <<"please Enter 6 values to fill the List :"; list.list=new int [6]; list.ReadArray(); cout<<endl; cout<<"the content of the first array are : "; list.PrintArray(); cout<<endl; cout <<"the number of the positive values inside the first list is "<<list.PositiveCount()<<endl; int size; size =list.PositiveCount(); ArrayList List(size); List.copyPositiveValues(list); cout <<"The size of the second list is :" << size<<"and the content of the second list is " ; List.PrintArray() ; } |
||||
|
|||||
| اقتباس المشاركة |
| الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
|