中央論壇 - CENTER BBS

標題: 關於一個c++的程式 [打印本頁]

作者: ann7622    時間: 2009-1-5 12:39
標題: 關於一個c++的程式
題目~設計一個可以進行加入,刪除,聯集,交集等運算的程式


相關說明:
1.集合元素為char型態,元素可為a~z任一小寫字元,其他字元不接受
2.有兩個集合SET1和SET2,允許使用者選擇要運作的集合,再加入或刪除其中的元素
3.然後輸出要能顯示出SET1和SET2各自的元素內容,與彼此的交集.聯集

以下是我找來的程式碼,有人已經幫我看了說少了main主程式
可以請大大幫我寫嗎???幫我把這個程式用完整>"<
我的msn:ann7622@yahoo.com.tw

能幫助的大大我真的會很感激@"@

#include<stdio.h>
#define TRUE 1
#define FALSE 0

typedef int BOOL;

/* set[0]: element 'a'; set[1]: element 'b' etc.
* the value 'TRUE' mean the character is the member of this set
*/

BOOL set1[26], set2[26];




BOOL Add_Element (BOOL *set, int element)
{
int index;


index = element-'a';
if ( index <0 || index> 26 )
return FALSE;

set[index] |= TRUE;
return TRUE;
}



BOOL Del_Element (BOOL *set, int element)
{
int index;


index = element-'a';
if ( index <0 || index> 26 )
return FALSE;

set[index] = FALSE;
return TRUE;
}


void Set_Union (BOOL *result_set, BOOL *set1, BOOL *set2)
{
int i;

for ( i=0; i<26; i++)
result_set = set1 || set2;
}

void Set_Intersect (BOOL *result_set, BOOL *set1, BOOL *set2)
{
int i;

for ( i=0; i<26; i++)
result_set = set1 && set2;
}

void Show_Element(BOOL *set)
{
int i;

for ( i=0; i<26; i++)
{
if ( set == TRUE )
printf ( "%c ", i+'a' );
}
}




歡迎光臨 中央論壇 - CENTER BBS (https://www.centerbbs.com/) Powered by Discuz! X3