Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream odczyt("gra.txt");
- int main()
- {
- int licznik=0;
- char tab[12][20];
- for (int i = 0;i<12;i++)
- {
- for(int j=0;j<20;j++)
- {
- odczyt>>tab[i][j];
- cout<<tab[i][j];
- }
- cout<<endl;
- }
- for(int i = 0;i<12;i++)
- {
- for (int j = 0 ;i<20;i++)
- {
- if(tab[i-1][j-1]=='X')
- {
- licznik++;
- }
- if(tab[i][j-1]=='X')
- {
- licznik++;
- }
- if(tab[i+1][j-1]=='X')
- {
- licznik++;
- }
- if(tab[i][j-1]=='X')
- {
- licznik++;
- }
- if(tab[i][j+1]=='X')
- {
- licznik++;
- }
- if(tab[i+1][j-1]=='X')
- {
- licznik++;
- }
- if(tab[i+1][j]=='X')
- {
- licznik++;
- }
- if(tab[i+1][j+1]=='X')
- {
- licznik++;
- }
- if(licznik==3)
- {
- tab[i][j]='X';
- }
- if(licznik>=4 || licznik==0 || licznik==1)
- {
- tab[i][j]='.';
- }
- }
- }
- cout<<endl;
- cout<<endl;
- for(int i = 0;i<12;i++)
- {
- for(int j = 0;j<20;j++)
- {
- cout<<tab[i][j];
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement