Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
life
#include <iostream> #include <fstream> #include <cstdlib> #include <cmath> #include <ctime> #include <cstdio> #include <string> #include <iomanip> #include <cstring> #include <cctype> using namespace std; int main(){ const int n=50; char meno=45; char piu=43; int vive=0; char campo[n][n]; //indecisione fra char, int , bool for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ campo[i][j]=meno; } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cout<<campo[i][j]<<" "; } cout<<endl; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ viva=0; if(campo[i][j]==meno){ for(int k=i-1;k<=i+1;k++){ for(int z=j-1;z<=j+1;z++){ if(campo[k][z]==piu) viva++; } } if(viva==3) campo[i][j]=piu; } else{ for(int k=i-1;k<=i+1;k++){ for(int z=j-1;z<=j+1;z++){ if(campo[k][z]==piu) viva++; } } viva--; if(viva<2 || viva>3) campo[i][j]=meno; } } } } }
run
|
edit
|
history
|
help
0
0002
resize.c
Recorrido matriz bidimensional y busqueda valor
Ecuación de segundo grado
C - Append Character to String
Numero pi Euler
Lazy dope vectors by Henry Kroll III www.thenerdshow.com
lab7_OOP 0.3 alha
Ashar
13 12 2014 20:25