/*--------------------------------------------------------------------*\ TRYST Problem #1 Compiles under Platform : Turbo C++ ------------ ( BGI graphics files req. for optional GRAPHICS display ) ARCHIPELAGO A computer program to calculate number of Islands in a given Map ..including ..GRAPHICS.. display Designed and programmed by: ASHISH GUPTA A-2 , Jwalamukhi 98131 B.Tech COMPUTER SCIENCE AND ENGINEERING IITD The input file must be a simple text file (ASCII format) : consisting of 1s and 0s Sample : --------- 1010101 1000101 0010101 1000101 the height and width need not be specified ( Automatic Detection in this program ) ( works for any m X n Grid ) \*--------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include //_________________Global Functions_______________ void Clean_Island(int y,int x); void Fill_Map(); void Display_Map(int**); void Display_VGA(int** map); void Animate(char* s,int x,int y); void Normal(); void Reverse(); void Intro(); //_________________Global Variables___________ int icount=0; int W=0; int H=0; int **map; int **resultmap; void main() { int x=0; int y=0; cout << endl<0 && map[y-1][x]==1) Clean_Island(y-1,x); if(x<(W-1) && map[y][x+1]==1) Clean_Island(y,x+1); if(x>0 && map[y][x-1]==1) Clean_Island(y,x-1); if(y<(H-1) && x0 && map[y+1][x-1]==1) Clean_Island(y+1,x-1); if(y>0 && x>0 && map[y-1][x-1]==1) Clean_Island(y-1,x-1); if(y>0 && x=W && strlen(buffer)>0) { W=strlen(buffer); h++; } } H=h; //_______Allocate sufficient memory for map_________ map=new int*[H+1]; for(int i=0;i0) { for(int i=0;i=0;i--) { for(j=1;j<=(i+x-1);j++) { buffer[0]=s[i]; Reverse(); gotoxy(j,y); cputs(buffer); sound(200+j*50); delay(1); nosound(); if(j<(i+x-1)) { gotoxy(j,y); Normal(); cputs(" "); } } } Normal(); } void Reverse() { textcolor(0); textbackground(7); } void Normal() { textcolor(7); textbackground(0); } void Intro() { cout << "\nWelcome to ARCHIPELAGO !"; cout << "\nThis program finds the number of continuous land masses"; cout << "\nin a sea. The MAP is input as a simple ASCII text file "; cout << "\nof 1s and 0s. 1 indicates land and 0 indicates water."; cout << "\nIt even displays a Graphical Display of the MAP using"; cout << "\ndifferent colors for islands making it easy to distinguish"; cout << "\nbetween different islands !"; cout << "\nNote : Location of Turbo C++ BGI Graphics drivers must be specified"; cout << "\nwhen asked for.\n"; cout << "\nSAMPLE FILE"; cout << "\n------------"; cout << "\n10001001"; cout << "\n10010001"; cout << "\n10001001"; cout << "\n00001001"; cout << "\n\nThe program automatically detects the width and height of the MAP"; cout << "\nNote : Allows m X n maps also."; cout << endl ; }