資源簡介
C語言 地圖染色問題 非遞歸 源代碼 下載

代碼片段和文件信息
#include?“stdio.h“
#include?“math.h“
#include?“stdlib.h“
int?data[8][8]={{00000000}{00100101}{01001010}
???{00000011}{00100011}{01000001}{00111000}
???{01011100}};
int?color[8]total;
int?check(int?s)
{
int?i;
????for?(i=1;i<=s-1;i++)
if?(data[i][s]==1&&color[i]==color[s])
return?0;
return?1;
}
void?output()
{
????int?i;
printf(“serial?number:%d\n“total);
for?(i=1;i<=7;i++)
printf(“%d“color[i]);
printf(“\n“);
total++;
}
void?paint(int?n)
{
int?k;
color[1]=0;
k=1;
while(k>0)
{
color[k]=color[k]+1;
while(color[k]<=4&&check(k)==0)
color[k]=color[k]+1;
if(color[k]<=4)
if(k==n)
output();
else
{
k=k+1;
color[k]=0;
}
else
k=k-1;
}
}
void?main()
{
???int?ij;
?/*??printf(“請輸入鄰接矩陣:\n“);
???for?(i=1;i<=7;i++)
???{
???for?(j=1;j<=7;j++)
???scanf(“%d“&data[i][j]);
???}
???*/
???for?(j=1;j<=7;j++)
???color[j]=0;
???total=0;
???paint(7);
?}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1033??2009-05-10?21:30??地圖問題非遞歸\11.cpp
?????文件???????3353??2009-05-10?20:58??地圖問題非遞歸\11.dsp
?????文件????????527??2009-05-10?21:16??地圖問題非遞歸\11.dsw
?????文件??????41984??2009-05-11?16:55??地圖問題非遞歸\11.ncb
?????文件??????48640??2009-05-11?16:55??地圖問題非遞歸\11.opt
?????文件???????1142??2009-05-10?21:30??地圖問題非遞歸\11.plg
?????文件?????172067??2009-05-10?21:30??地圖問題非遞歸\Debug\11.exe
?????文件?????174552??2009-05-10?21:30??地圖問題非遞歸\Debug\11.ilk
?????文件???????5118??2009-05-10?21:30??地圖問題非遞歸\Debug\11.obj
?????文件?????230232??2009-05-10?21:23??地圖問題非遞歸\Debug\11.pch
?????文件?????443392??2009-05-10?21:30??地圖問題非遞歸\Debug\11.pdb
?????文件??????33792??2009-05-10?21:30??地圖問題非遞歸\Debug\vc60.idb
?????文件??????45056??2009-05-10?21:30??地圖問題非遞歸\Debug\vc60.pdb
?????目錄??????????0??2009-05-22?18:28??地圖問題非遞歸\Debug
?????目錄??????????0??2009-05-22?18:28??地圖問題非遞歸
-----------?---------??----------?-----??----
??????????????1200888????????????????????15
- 上一篇:c++利用數組實現簡單的奇偶校驗
- 下一篇:c++實現數字轉換英文無and
評論
共有 條評論