المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : مساعدة ممكن



فرنسية
15-12-2008, 10:56 PM
اريد هذان البرنامجان ب c++,ولو حتى اللي فهم المطلوب من السؤال يقول لي لانه ما اعرف المطلوب اصلا

Write a function that removes all duplicates in array A of N times.Return the number of itemes that remain in A.your function must run in O(Nlog N)averge time (use quicksort as a preprocessing step )


The sieve of Eratosthenenes is a method used to compute all primes less than N
Being by making a table of integers from 2to N.FIND THE SMAALLEST INTGER ,i,That
Is not acorossed out .THEN print I and cross out i,2i,3i..when i>N,the algorimm terminates

AZPC
20-12-2008, 04:53 PM
هذه بالنسبة للسؤال الاول ,,



int myfunction (int A[], int size);
void main ()
{
int R[10] = {1,2,3,3,3,4,5,6,7,7};
cout<<myfunction(R,10)<<endl;
}

int myfunction (int A[], int size)
{
int N = 0;
int temp = 0;

for(int i = 0 ; i < (size - N) ; i++)
{
if(A[i] == A[i+1])
{
temp = A[i];
A[i] = A[size - i];
A[size - i] = temp;
N++;
}
}
size = size - N;
return size;
}



Edit whatever needed to be edited .. good luck ,, I hope I helped

دعواتج لا تنسينا :)

فرنسية
25-12-2008, 11:05 PM
جزاك الله خير