dna.cpp

来自「简单的模拟DNA配对的程序」· C++ 代码 · 共 62 行

CPP
62
字号
#include <iostream>#include <fstream>using namespace std;#include "dna.h"static int numChar = 0;					// store count of bytesstatic const int MAX = 3000;			// maximum width of arraystatic char DNAstrand[MAX];				// store strandvoid reverse(ifstream& fin)		// reverse function{	while(!fin.eof())	{		fin.get(DNAstrand[numChar]);		if (fin.good())		{			if (DNAstrand[numChar] != '\n')				numChar++;		}		else			break;	}		// swap bytes		for(int i = 0; i < numChar; i++)	{		if(DNAstrand[i] == 'A')			DNAstrand[i] = 'T';				else if(DNAstrand[i] == 'C')			DNAstrand[i] = 'G';				else if(DNAstrand[i] == 'G')			DNAstrand[i] = 'C';				else if(DNAstrand[i] == 'T')			DNAstrand[i] = 'A';		}			// print	for(int j = numChar-1; j >= 0; j--)		cout << DNAstrand[j];		return;}void save(ofstream& fout)	// save function{	if(fout.good())	{				for(int k = numChar-1; k >= 0; k--)		{			fout.put(DNAstrand[k]);		}			}		fout.close();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?