請選擇 進入手機版 | 繼續訪問電腦版
搜索
熱搜: 活動 交友 discuz
查看: 8980|回復: 0

[求助] 關於一個c++的程式

[複製鏈接]
發表於 2009-1-5 12:39:29 | 顯示全部樓層 |閱讀模式
題目~設計一個可以進行加入,刪除,聯集,交集等運算的程式


相關說明:
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' );
}
}
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

本論壇為非營利之網路平台,所有文章內容均為網友自行發表,不代表論壇立場!若涉及侵權、違法等情事,請告知版主處理。


Page Rank Check

廣告刊登  |   交換連結  |   贊助我們  |   服務條款  |   免責聲明  |   客服中心  |   中央分站

手機版|中央論壇

GMT+8, 2024-3-29 14:15 , Processed in 0.017724 second(s), 18 queries .

Powered by Discuz!

© 2005-2015 Copyrights. Set by YIDAS

快速回復 返回頂部 返回列表