Advertisement
hugol

Untitled

Dec 6th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. const int n=5;
  7. const int m=5;
  8.  
  9. void wyczysc (char plansza[n][m])
  10. {
  11.     int i,j;
  12.     for (i=0; i<n; i++){
  13.         for (j=0; j<m; j++){
  14.             plansza[i][j]=0;
  15.         }
  16.     }
  17. }
  18.  
  19. void wypisz (char plansza[n][m])
  20. {  
  21.     for(int i=0; i<n; i++){
  22.         for(int j=0; j<m; j++){
  23.             cout<<setw(6)<<"+-----";
  24.             plansza[i][j];
  25.         }
  26.         static int y=y++;// wtf?
  27.         // dodalem
  28.         cout<<"+"<< i <<endl;
  29.         // wypiswanie kolejnych komorek w poziomie
  30.         for(int x=0; x<2; x++){
  31.             for(int mm=0; mm<m; mm++){
  32.                 if (plansza[i][mm])
  33.                 {
  34.                     cout<<"|#####";
  35.                 }
  36.                 else
  37.                 {
  38.                     cout<<"|     ";
  39.                 }
  40.  
  41.             }
  42.             cout<<"|" <<endl;
  43.         }
  44.  
  45.     } cout<<"+-----+-----+-----+-----+-----+"<<endl;
  46.     for(int z=0; z<m; z++){
  47.         cout<<"   "<< z << setw(5);
  48.     }
  49.     cout<<endl<<endl;
  50.  
  51.  
  52. }
  53.  
  54. void wstawianie(char gracz, char plansza[n][m]) {
  55.     int wiersz;
  56.     int kolumna;
  57.     do {
  58.         wiersz=6;
  59.         kolumna=6;
  60.         while(wiersz<0 || wiersz>5) {
  61.             cout << "Gracz "<<gracz<<": Podaj wiersz (0,1,2,3,4,5): ";
  62.             cin >> wiersz;
  63.             if(wiersz<0 || wiersz>5)
  64.                 cout << "Nie ma takiego wiersza"<<endl;
  65.         }
  66.         while(kolumna<0 || kolumna>5) {
  67.             cout << "Gracz "<<gracz<<": Podaj kolumne (0,1,2,3,4,5): ";
  68.             cin >> kolumna;
  69.             if(kolumna<0 || kolumna>5)
  70.                 cout << "Nie ma takiej kolumny"<<endl;
  71.         }
  72.         if(plansza[wiersz][kolumna] != 0)
  73.             cout << "To pole jest juz zajete"<<endl;
  74.     } while(plansza[wiersz][kolumna] != 0);
  75.  
  76.  
  77.     if(gracz=='X') plansza[wiersz][kolumna] = 1;
  78.     else plansza[wiersz][kolumna] = 2;
  79. }
  80.  
  81.  
  82.  
  83. int main() {
  84.  
  85.     char plansza[n][m];
  86.     int y;
  87.     char X;
  88.  
  89.     cout<<"Gra w Kamienie ;)"<<endl;
  90.     cout<<"=================="<<endl<<endl;
  91.  
  92.     wyczysc(plansza);
  93.  
  94.     plansza[1][0] = 1;
  95.  
  96.     plansza[2][3] = 1;
  97.  
  98.  
  99.     wypisz(plansza);
  100.    
  101.     wstawianie('X', plansza);
  102.     return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement