askarulytarlan

расшифровка генома мамонта

Jan 5th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <string.h>
  5.  
  6. using namespace std;
  7.  
  8. int n;
  9. string s;
  10. int cnt[5];
  11. int mx;
  12.  
  13. int main() {
  14. cin >> n;
  15. cin >> s;
  16. for(int i = 0; i < 5; i++){
  17. cnt[i] = 0;
  18. }
  19. for(int i = 0; i < n; i++){
  20. if(s[i] == 'A'){
  21. cnt[0]++;
  22. }
  23. if(s[i] == 'G'){
  24. cnt[1]++;
  25. }
  26. if(s[i] == 'C'){
  27. cnt[2]++;
  28. }
  29. if(s[i] == 'T'){
  30. cnt[3]++;
  31. }
  32. if(s[i] == '?'){
  33. cnt[4]++;
  34. }
  35. }
  36. mx = n / 4;
  37. int l = (mx * 4)-(cnt[0] + cnt[1] + cnt[2] + cnt[3]);
  38. bool k = 0;
  39. if(s.size() % 4 != 0){
  40. cout << "===" << endl;
  41. return 0;
  42. }
  43. for(int i = 0; i < 4; i++){
  44. if(cnt[i] * 4> s.size()){
  45. cout << "===" << endl;
  46. return 0;
  47. }
  48. }
  49. for(int i = 0; i < n; i++){
  50. if(s[i] == '?'){
  51. for(int j = 0; j < 4; j++){
  52. if(cnt[j] < mx && k == 0){
  53. if(j == 0){
  54. s[i] = 'A';
  55. cnt[0]++;
  56. }
  57. else if(j == 1){
  58. s[i] = 'G';
  59. cnt[1]++;
  60. }
  61. else if(j == 2){
  62. s[i] = 'C';
  63. cnt[2]++;
  64. }
  65. else if(j == 3){
  66. s[i] = 'T';
  67. cnt[3]++;
  68. }
  69. k = 1;
  70. }
  71. }
  72. k = 0;
  73. }
  74. }
  75. cout << s << endl;
  76. return 0;
  77. }
Add Comment
Please, Sign In to add comment