UVa 457 - Linear Cellular Automata
来源:互联网 发布:阿里云1m带宽看 视频 编辑:程序博客网 时间:2024/05/04 12:27
题目大意(From Sina Blog:xiaohe):
个生物学家堆在一排并排着的培养皿中的细菌群体进行DNA序列修改来进行相关测试,通过改变DNA
他可以让细菌对邻近培养皿里的种群浓密度产生反应,群体密度用4个状态标示(0~3)DNA的状态通过
下标为0~9的数组描述,具体如下:
对应数组序列DNA[K]的种群密度。
现在我们清楚的知道一些DNA程式会导致所有的菌落死亡,(像[0,0,0,0,0,0,0,0,0,0])另外一些会令其
快速生长([3,3,3,3,3,3,3,3,3,3])生物学家对这些更小的媒介DNA程式是如何运作的很感兴趣。
写一个程序模仿40个并排着的细菌培养皿的生长状况,假设第20个起始密度为1,其他的为0
输入
先输入案例个数
然后输入密度变化规律
输出
密度为1输出' ',2输出'.',3输出'x',4输出'W'。
例如:
输入十个序列值存储在数组中
0 1 2 0 1 3 3 2 3 0
如果第n天第i个培养皿与其左边和右边的密度之和为(1+2+1=4),则第i+1天第i个培养皿的密度就是第五个
(以数组存储下表为4的元素)值3
本题之列出了十天的变化,程序要列出五十天的四十个培养皿的变化
============================================================================这个题不难,但是对我来说还是有很多细节问题要注意:
1.粗心,开始时开的数组是int dna[10],jun[50][40],后来发现不够用开成45后,下面有两个for循环的循环条件要由40改为41,
但是由于粗心忘了改了,后来发现问题后也改了,但是只改了第一个,导致输出时少最后一列。纠结了好一会儿。
2.题目的要求是在每个例子之间 输出空格,我以为是每个之后,导致一次WA的严重后果。切记切记!
===========================================================================
/*Author:GneveekData: 2011-10-1Source: UVa 457 - Linear Cellular Automata*/#include <stdio.h>#include <string.h>int dna[10],jun[50][45];int main(){//freopen("D:\\data.in","r",stdin);//freopen("D:\\data2.out","w",stdout);int n,i,j,temp;scanf("%d",&n);while(n--){for(i=0; i<10; i++)scanf("%d",&dna[i]);memset(jun,0,sizeof(jun));jun[0][20] = 1;for(i=1; i<50; i++){for(j=1; j<41; j++){temp = jun[i-1][j-1] + jun[i-1][j] + jun[i-1][j+1];jun[i][j] = dna[temp];}}for(i=0; i<50; i++){for(j=1; j<41; j++){switch (jun[i][j]){case 0:putchar(' ');break;case 1:putchar('.');break;case 2:putchar('x');break;case 3:putchar('W');break;}}putchar('\n');}if(n>0)putchar('\n');}return 0;}
- UVa 457 - Linear Cellular Automata
- uva-457-Linear Cellular Automata
- UVA 457 - Linear Cellular Automata
- UVA 457 - Linear Cellular Automata
- UVA 457 - Linear Cellular Automata
- uva 457 Linear Cellular Automata
- UVa 457 - Linear Cellular Automata
- UVa 457 - Linear Cellular Automata
- UVA 457 Linear Cellular Automata
- UVA - 457 Linear Cellular Automata
- UVA-457-Linear Cellular Automata
- UVA - 457 Linear Cellular Automata
- uva Linear Cellular Automata
- UVA OJ 457 - Linear Cellular Automata
- UVa 457 Linear Cellular Automata (water ver.)
- UVa - 457 - Linear Cellular Automata 题解
- uva 457 Linear Cellular Automata(模拟)
- UVA - 457 Linear Cellular Automata(水题)
- “数组a,长度为n(索引为0至n-1)。现要求更新数组的各个元素,使新数组的第i个元素等于原数组中除第i个元素之外各元素之积。”
- 草根创业回忆录一: 踏出了第一步的时候...
- linux模块编程(四)——消息的使者list
- getopt 详解 linux
- 草根创业回忆录二: 都选择的是什么人?
- UVa 457 - Linear Cellular Automata
- 创业公司的CEO每周须必做的13件事
- OGNL表达式 #%$
- ZOJ题目汇总
- 企业经营是一个孩子的培育过程
- 创业管好哪个事情最重要
- 小企业如何用"心"去发展
- 使用 ibatis 处理复杂对象数据关系的实例
- 乔布斯的人生历程