Zoj1051 a new growth industry

Source: Internet
Author: User

This question is too difficult to understand the question. It is actually a simple array processing, adding up and down to the left and right, and then adding the obtained value to the current item in the table, if this parameter is exceeded, it is processed.

# Include <iostream>
Using namespace STD;

Const int maxnum = 20; // the size of the petri dish is * 20
Char signtable [] = ".! X # "; // symbol table
Int dish [maxnum] [maxnum], Res [maxnum] [maxnum];
Int day, d [16];

Int main ()
{
INT cases; // Number of test samples
Int I, J, K;
While (CIN> Cases)
{
While (cases --)
{
Cin> day; // day of training
// Input the DNA sequence information
For (k = 0; k <16; ++ K)
Cin> d [k];
// Enter the petri dish data
For (I = 0; I <maxnum; ++ I)
For (j = 0; j <maxnum; ++ J)
Cin> dish [I] [J];
While (day --)
{
For (I = 0; I <maxnum; ++ I)
For (j = 0; j <maxnum; ++ J)
{
K = dish [I] [J];
// Combine with upper, lower, and left
If (I-1> = 0)
K + = dish [I-1] [J];
If (I + 1 <maxnum)
K + = dish [I + 1] [J];
If (J-1> = 0)
K + = dish [I] [J-1];
If (J + 1 <maxnum)
K + = dish [I] [J + 1];
Res [I] [J] = dish [I] [J] + d [k];
// Cannot exceed 0 ~ Range 3
If (RES [I] [J]> 3)
Res [I] [J] = 3;
If (RES [I] [J] <0)
Res [I] [J] = 0;
}
Memcpy (dish, res, sizeof (dish ));
}
For (I = 0; I <maxnum; ++ I)
{
For (j = 0; j <maxnum; ++ J)
Cout <signtable [dish [I] [J];
Cout <Endl;
}
// There is an empty line between the samples
If (cases! = 0)
Cout <Endl;
}
}
Return 0;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.