Phoenix_Hijacker

junkstyle

Feb 26th, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <iomanip>
  4. #include <ctime>
  5. using namespace std;
  6. int main(){
  7.         system("clear");
  8.         #define RESET   "\033[0m"
  9.     #define BLACK   "\033[30m"      /* Black */
  10.     #define RED     "\033[31m"      /* Red */
  11.     #define GREEN   "\033[32m"      /* Green */
  12.     #define YELLOW  "\033[33m"      /* Yellow */
  13.     #define BLUE    "\033[34m"      /* Blue */
  14.     #define MAGENTA "\033[35m"      /* Magenta */
  15.     #define CYAN    "\033[36m"      /* Cyan */
  16.     #define WHITE   "\033[37m"      /* White */
  17.     #define BOLDBLACK   "\033[1m\033[30m"      /* Bold Black */
  18.     #define BOLDRED     "\033[1m\033[31m"      /* Bold Red */
  19.     #define BOLDGREEN   "\033[1m\033[32m"      /* Bold Green */
  20.     #define BOLDYELLOW  "\033[1m\033[33m"      /* Bold Yellow */
  21.     #define BOLDBLUE    "\033[1m\033[34m"      /* Bold Blue */
  22.     #define BOLDMAGENTA "\033[1m\033[35m"      /* Bold Magenta */
  23.     #define BOLDCYAN    "\033[1m\033[36m"      /* Bold Cyan */
  24.     #define BOLDWHITE   "\033[1m\033[37m"      /* Bold White */
  25.     const int n=10;
  26.     int maxships=3,ships=0,asse_x,asse_y,x,y,a;
  27.     char map1[n][n]={},map2[n][n]={};
  28.     srand(time(0));
  29.     char map[n][n]={};
  30.  
  31.     for(int i =0;i<n;i++){
  32.         for(int j=0;j<n;j++)
  33.            map[i][j]='*';
  34.         }
  35.         for(int i =0;i<n;i++){
  36.         for(int j=0;j<n;j++)
  37.            map1[i][j]='*';
  38.         }
  39.  
  40.     {
  41.      x=rand()%n;
  42.      y=rand()%n;     
  43.      map1[x][y]='#';
  44.     }
  45.    
  46.      
  47.      cout<<x<<" "<<y<<endl;
  48.      cout<< "               ♣ Battaglia Navale ♣\n\n\n"<<endl;
  49.     // Stampa solo per la prima volta or stampa la mare
  50.     for(int i =0;i<n;i++){
  51.         for(int j=0;j<n;j++)
  52.           cout<<CYAN<<setw(3)<< map[i][j]<<RESET;
  53.         cout<<endl;  
  54.         }  
  55.          
  56.    
  57.     //attack  or guess
  58.      do{
  59.          asse_x=0;asse_y=0;
  60.    
  61.    
  62.     cout<<"Insersci la coordinata di righa (numero intero): ";
  63.     cin>>asse_x;
  64.         cout<<"Insersci la coordinata in colonna (numero intero):";
  65.     cin>>asse_y;
  66.  
  67.  
  68.  
  69.  
  70.     if(map1[asse_x][asse_y]== map1[x][y]){
  71.        cout<<BOLDGREEN<<"\n\n\n"<<setw(23)<<"VINTO\n\n"<<RESET<<endl;
  72.        a++;
  73.            for(int i =0;i<n;i++){
  74.           for(int j=0;j<n;j++)
  75.                 if(map1[asse_x][asse_y]!=map1[i][j])
  76.              cout<<"  "<<CYAN<< map1[i][j]<<RESET;
  77.                 else
  78.           cout<<BOLDGREEN<<setw(3)<< map[x][y]<<RESET;
  79.            
  80.           cout<<endl;
  81.          
  82.            }
  83.  
  84.     }
  85.        
  86.     else
  87.     {
  88.       cout<<BLUE<<"\n\n\n"<<"Fallito il Tentativo\n\n"<<endl;
  89.           cout<<RESET;
  90.           map[asse_x][asse_y]='o';
  91.           for(int i =0;i<n;i++){
  92.         for(int j=0;j<n;j++)
  93.                if(map[i][j]==map[asse_x][asse_y])
  94.              cout<<CYAN<<setw(3)<< map[i][j]<<RESET;
  95.                else
  96.         cout<<YELLOW<<setw(3)<< map[i][j]<<RESET;              
  97.         cout<<endl;            
  98.           }
  99.        
  100.         }  
  101.      
  102.  
  103.     if(map1[asse_x][asse_y]== map1[x][y])
  104.        break;
  105.     }while(1);
  106. return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment