📄 dna.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -