题目链接:Linear Cellular Automata UVA - 457
#include <iostream>
#include <cstdio>
using namespace std;
const int N=10;
const int M=40;
const int D=50;
int dna[N];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a[M+2]={0},tem[M+2]={0};
for(int i=0;i<N;i++)
scanf("%d",&dna[i]);
a[M/2]=1;
for(int i=0;i<D;i++)
{
for(int j=1;j<=M;j++)
{
if(a[j]==0)
putchar(' ');
else if(a[j]==1)
putchar('.');
else if(a[j]==2)
putchar('x');
else
putchar('W');
tem[j]=dna[a[j-1]+a[j]+a[j+1]];
}
putchar('\n');
for(int j=1;j<=M;j++)
a[j]=tem[j];
}
if(t)
putchar('\n');
}
return 0;
}