ابزار لودینگ وبلاگ

|

ابزارهای وبلاگ نویسی

برنامه ای بنویسید که با استفاده از یک تابع، اشتراک دو مجموعه را محاسبه و چاپ نماید؟

























با جدایی هیچی تموم نمیشه

Separation does not mean the end of our love

void intersection(const int A[ ], int na, const int B[ ], int nb, int C[ ], int &nc) {
k = 0;
for (i=0; i< na; i++) {
sw = 1;
for (j=0; j< nb && sw; j++)
if (A[i] == B[j]) {
C[k] = A[i] ;
k ++;
sw = 0;
}
}
nc = k;
}
void printSet(int set[], int size) {
int i;
printf(“{ “) ;
for (i=0; i< size; i++)
printf(”%d ”,set[i]) ;
printf(“}\n”);
}

void main() {
int set1[5] = {5, 8, 3, 12, 20};
int set2[3] = {12, 16, 8} ;
int result[3] , resultSize ;
intersection(set1, 5, set2, 3, result, resultSize);
printf(“set 1 = “);
printSet(set1) ;
printf(“set 2 = “);
printSet(set2) ;
printf(“intersection = “);
printSet(result) ;
}

نوشته شده در دوشنبه پانزدهم بهمن ۱۳۸۶ساعت 11:50 توسط اهورا|


آخرين مطالب
» رفتی
» بودنت
» مردم برای عشق
» گر
» تشنگی
» رَد نمیشود
» خونه‌
» خودم خواستم
» ترس
» دوباره دیدنش
Design By : AHORA