Zoj 1051 a new growth industry {4597}
Ah ~ The zoj 2433, which was originally made yesterday, has an ACM. My mother no longer needs to worry about reading English. Today, I met another 1051. Think of Thursday afternoon. I even accidentally discovered that the senior student asked about this question on another blog. It turned out that the great God worked a little harder.
Read the question, the question is to give a 20*20 matrix, the above number is the basis, and then add up and down to get a number, this number is the subscript of the corresponding growth trend value. Based on the trend, change this basic number and then output the corresponding symbol.
Code:
#include<stdio.h>int main(){int i,g,N,n,j,k,f,t,d[20];int c[22][22] = {0};int a[22][22] = {0};scanf("%d",&N);for(j = 1;j<=N;j++){getchar();scanf("%d",&n);for(t = 0;t<=15;t++){scanf("%d",&d[t]);}for(g = 1;g<=20;g++){for(f = 1;f<=20;f++){scanf("%d",&a[g][f]);}}for(k = 1;k<=n;k++){for(g = 1;g<=20;g++){for(f = 1;f<=20;f++){c[g][f] = a[g][f-1]+a[g][f+1]+a[g-1][f]+a[g+1][f]+a[g][f];}}for(g = 1;g<=20;g++){for(f = 1;f<=20;f++){t = c[g][f];a[g][f] = a[g][f]+d[t];if(a[g][f]<0)a[g][f] = 0;if(a[g][f]>3)a[g][f] = 3;}}}for(g = 1;g<=20;g++){for(f = 1;f<=20;f++){if(a[g][f]==0)printf(".");if(a[g][f]==1)printf("!");if(a[g][f]==2)printf("X");if(a[g][f]==3)printf("#");}printf("\n");}if(j!=N)printf("\n");getchar();}return 0;}