以下是题目和我的代码,提交之后是wrong answer,还请各位大神帮忙看看哪里错误,万分感谢!!!

Description
A biologist experimenting with DNA modification of bacteria has found a way to make bacterial colonies sensitive to the surrounding population density. By changing the DNA, he is able to “program” the bacteria to respond to the varying densities in their immediate neighborhood.
The culture dish is a square, divided into 400 smaller squares (20x20). Population in each small square is measured on a four point scale (from 0 to 3). The DNA information is represented as an array D, indexed from 0 to 15, of integer values and is interpreted as follows:
In any given culture dish square, let K be the sum of that square’s density and the densities of the four squares immediately to the left, right, above and below that square (squares outside the dish are considered to have density 0). Then, by the next day, that dish square’s density will change by D[K] (which may be a positive, negative, or zero value). The total density cannot, however, exceed 3 nor drop below 0.
Now, clearly, some DNA programs cause all the bacteria to die off (e.g., [-3, -3, …, -3]). Others result in immediate population explosions (e.g., [3,3,3, …, 3]), and others are just plain boring (e.g., [0, 0, … 0]). The biologist is interested in how some of the less obvious DNA programs might behave.
Write a program to simulate the culture growth, reading in the number of days to be simulated, the DNA rules, and the initial population densities of the dish.

Input
Input to this program consists of three parts:

  1. The first line will contain a single integer denoting the number of days to be simulated.
  2. The second line will contain the DNA rule D as 16 integer values, ordered from D[0] to D[15], separated from one another by one or more blanks. Each integer will be in the range -3…3, inclusive.
  3. The remaining twenty lines of input will describe the initial population density in the culture dish. Each line describes one row of squares in the culture dish, and will contain 20 integers in the range 0…3, separated from one another by 1 or more blanks.

Output
The program will produce exactly 20 lines of output, describing the population densities in the culture dish at the end of the simulation. Each line represents a row of squares in the culture dish, and will consist of 20 characters, plus the usual end-of-line terminator.
Each character will represent the population density at a single dish square, as follows:
No other characters may appear in the output.

Sample Input
1
2
0 1 1 1 2 1 0 -1 -1 -1 -2 -2 -3 -3 -3 -3
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Sample Output
##!..
#!..
!..




…!..
…!#!..
…!#X#!..
…!#!..
…!..







#include
#include<stdio.h>
using namespace std;
int main(){
int day,d=1;//day是模拟的天数;
int dna[16];//DNA信息
int density1[22][22]={0},density2[22][22]={0};
int i,j;
cin>>day;
for(i=0;i<16;i++)scanf("%d",&dna[i]);
for(i=1;i<21;i++)
for(j=1;j<21;j++)
scanf("%d",&density1[i][j]);
while(day–){
d=1;//d代表现在是第几天
for(i=1;d%2!=0&&i<21;i++)
for(j=1;j<21;j++)
density2[i][j]=density1[i][j]+density1[i+1][j]+density1[i-1][j]+density1[i][j+1]+density1[i][j-1];
for(i=1;d%2==0&&i<21;i++)
for(j=1;j<21;j++)
density1[i][j]=density2[i][j]+density2[i+1][j]+density2[i-1][j]+density2[i][j+1]+density2[i][j-1];
d++;
}
for(i=1;d%2!=0&&i<21;i++){
for(j=1;j<21;j++){
if(density2[i][j]==0){cout<<".";continue;}
else if(density2[i][j]==1){cout<<"!";continue;}
else if(density2[i][j]2){cout<<“X”;continue;}
else cout<<"#";
}
cout<<endl;
}
for(i=1;d%20&&i<21;i++){

 for(j=1;j<21;j++){if(density1[i][j]==0){cout<<".";continue;}else if(density1[i][j]==1){cout<<"!";continue;}else if(density1[i][j]==2){cout<<"X";continue;}else cout<<"#";}cout<<endl;
}
return 0;

}

c++ acm题目1057 DNA培养问题相关推荐

  1. 杭电ACM题目类型整理

    版权声明:(╯3╰) 转载请注明: http://blog.csdn.net/bat67 杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 10 ...

  2. ACM题目中输入数据的处理(C++语言版)

    ACM题目中输入数据的处理(C语言版)见: http://blog.csdn.net/sxhelijian/article/details/8978794 ACM竞赛题目的输入数据常要求有多组,并且格 ...

  3. ACM题目 1012: [编程入门]字符串分类统计

    ACM题目 1012: [编程入门]字符串分类统计 题目描述 输入一行字符,分别统计出其中英文字母.数字.空格和其他字符的个数. 输入 一行字符 输出 统计值 样例输入 aklsjflj123 sad ...

  4. ACM题目中输入数据的处理(C++版)

    ACM题目中输入数据的处理(C语言版)见:http://blog.csdn.net/sxhelijian/article/details/8978794 ACM竞赛题目的输入数据常要求有多组,并且格式 ...

  5. ACM题目和培养训练!!!

    ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...

  6. PUK ACM题目分类

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  7. HDOJ ACM 题目

    转载 HDOJ 题目分类(转) 1001 整数求和 水题 1002 C语言实验题--两个数比较 水题 1003 1.2.3.4.5... 简单题 1004 渊子赛马 排序+贪心的方法归并 1005 H ...

  8. ACM题库以及培养策略

    ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...

  9. 浙大OJ网址及ACM题目分类

    转自: http://blog.sina.com.cn/s/blog_61beb97b0100kquq.html 浙大oj网址:http://acm.zju.edu.cn/onlinejudge/ 第 ...

最新文章

  1. 玉米田Corn Fields
  2. 这个宝藏工具,给你一种黑客般的感觉
  3. MYSQL 取中位数
  4. 实验四、主存空间的分配和回收模拟
  5. AOP:【动态代理】||@Pointcut
  6. 内存或磁盘空间不足,Microsoft Office Excel 无法再次打开或保存任何文档。 [问题点数:20分,结帖人wenyang2004]...
  7. linux期末作业设计,linux作业与项目设计
  8. Linux 查看磁盘或文件夹及文件大小
  9. linux一次执行多个命令,linux 一次执行多条命令
  10. Linux ---yum源详解
  11. 分类算法学习(一)——KNN算法的原理及简单实现
  12. 解决安卓的permission denied for this window type问题
  13. 将2^n (n=1000000) 转化为10进制输出
  14. 群晖系统服务器设置,私人云搭建 篇二:群晖系统搭建和初步设置的不正确指北...
  15. JAVA泛型_泛型类、接口、通配符、方法、上下边界
  16. 计算机wordif函数,wordif函数怎么用
  17. 【opencv】颜色空间总结
  18. html纵向广告滚动,jquery广告滚动 jquery 实现文字左右滚动
  19. exoplay切换全屏_02.视频播放器整体结构
  20. File和Filelnfo类

热门文章

  1. 我们到底在干什么? —— 一名普通程序员的心声
  2. 什么是Storm?从入门到上手使用
  3. 分期付款的利率不是这么算的!我用Python告诉你亏了多少!
  4. 同一个SQL引发多个ORA-7445错误
  5. HTC安装运行-公司项目
  6. 佟强老师的Java课件
  7. 高性能网络编程--陶辉
  8. Logback各Appender详解及配置
  9. CSS之美化网页(其二)
  10. 大型互联网公司如何防止黑客入侵(上)