今天刚刚看了数组...就做了老师留的实验...但是发现很多不懂的,想问一下这个程序为什么第四部分不能运行...怎么解决呢?
程序代码:
#include <stdio.h> #include <stdlib.h> int main() { char dna[200]; char mrna[200]; int length; int i; printf("请输入DNA单链序列(大写字母):\n"); gets(dna); length = strlen(dna); printf("%d\n",length); printf("%s\n",dna); /*第一部分,输出标准格式的DNA单链*/ printf("您所输入的DNA单链为:"); for(i = 0;i <= length-1 ; i++) { printf("-%c",dna[i]); } printf("-"); putchar('\n'); /*第二部分,输出对应的互补DNA单链*/ printf("其所对应的DNA单链为: "); for(i = 0; i <=length-1 ; i++) { if( dna[i] == 'A') printf("-T"); mrna[i] = 'T'; if( dna[i] == 'T') printf("-A"); if( dna[i] == 'G') printf("-C"); if( dna[i] == 'C') printf("-G"); } printf("-"); putchar('\n'); /*第三部分,输出对应的mRNA序列*/ printf("对应的mRNA序列为: "); for(i = 0; i <= length-1 ; i++) { if( dna[i] == 'T') { printf("-A"); mrna[i] = 'A'; } if( dna[i] == 'A') { printf("-U"); mrna[i] = 'U'; if( dna[i] == 'G') { printf("-C"); mrna[i] = 'C'; } if( dna[i] == 'C') { printf("-G"); mrna[i] = 'G'; } } printf("-"); putchar('\n'); printf("%c",mrna[]); /*第四部分,输出氨基酸顺序*/ printf("翻译合成的蛋白质的氨基酸序列为: \n"); for( i = 0; i <= length-4 ; i++) { if( mrna[i] == 'U' && mrna[i+1] == 'U' && (mrna[i+2] == 'U' || mrna[i+2] == 'C')) printf("-苯丙氨酸"); if( mrna[i] == 'U' && mrna[i+1] == 'U' && (mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-亮氨酸"); if( mrna[i] == 'U' && mrna[i+1] == 'C' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-丝氨酸"); if( mrna[i] == 'U' && mrna[i+1] == 'A' && (mrna[i+2] == 'U' || mrna[i+2] == 'C')) printf("-酪氨酸"); if( mrna[i] == 'U' && mrna[i+1] == 'A' && (mrna[i+2] == 'A' || mrna[i+2] == 'G')) break; if( mrna[i] == 'U' && mrna[i+1] == 'G' && mrna[i+2] == 'A') break; if( mrna[i] == 'U' && mrna[i+1] == 'G' && (mrna[i+2] == 'U' || mrna[i+2] == 'C')) printf("-半胱氨酸"); if( mrna[i] == 'U' && mrna[i+1] == 'G' && mrna[i+2] == 'G') printf("-色氨酸"); if( mrna[i] == 'C' && mrna[i+1] == 'U' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-亮氨酸"); if( mrna[i] == 'C' && mrna[i+1] == 'C' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-脯氨酸"); if( mrna[i] == 'C' && mrna[i+1] == 'A' && (mrna[i+2] == 'U' || mrna[i+2] == 'C')) printf("-组氨酸"); if( mrna[i] == 'C' && mrna[i+1] == 'A' && (mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-谷氨酰胺"); if( mrna[i] == 'C' && mrna[i+1] == 'G' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-精氨酸"); if( mrna[i] == 'A' && mrna[i+1] == 'U' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A')) printf("-异亮氨酸"); if( mrna[i] == 'A' && mrna[i+1] == 'U' && mrna[i+2] == 'G') printf("-甲硫氨酸"); if( mrna[i] == 'A' && mrna[i+1] == 'C' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-苏氨酸"); if( mrna[i] == 'A' && mrna[i+1] == 'A' && (mrna[i+2] == 'U' || mrna[i+2] == 'C')) printf("-天冬酰胺"); if( mrna[i] == 'A' && mrna[i+1] == 'A' && (mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-赖氨酸"); if( mrna[i] == 'A' && mrna[i+1] == 'G' && (mrna[i+2] == 'U' || mrna[i+2] == 'C')) printf("-丝氨酸"); if( mrna[i] == 'A' && mrna[i+1] == 'G' && (mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-精氨酸"); if( mrna[i] == 'G' && mrna[i+1] == 'U' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-缬氨酸"); if( mrna[i] == 'G' && mrna[i+1] == 'C' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-丙氨酸"); if( mrna[i] == 'G' && mrna[i+1] == 'A' && (mrna[i+2] == 'U' || mrna[i+2] == 'C')) printf("-天冬氨酸"); if( mrna[i] == 'G' && mrna[i+1] == 'A' && (mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-谷氨酸"); if( mrna[i] == 'G' && mrna[i+1] == 'U' && (mrna[i+2] == 'U' || mrna[i+2] == 'C' || mrna[i+2] == 'A' || mrna[i+2] == 'G')) printf("-甘氨酸"); } return 0; }是不是那个mrna[]用错了?该怎么用,才能给它赋值?