Question

Q)Supposed we have a string seq= "ACGTGT" . Given a value n, find all posible outcomes...

Q)Supposed we have a string seq= "ACGTGT" . Given a value n, find all posible outcomes of N'mers. Write a C++ function to do so. You can only use loops or nested loops.

For example if n=3 then the posible combinations are and your output should be ACG CGT GTG TGT.

Note: You can only use loops/nested loops to do so.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <string>

using namespace std;

int main() {
   string str = "ACGTGT";
   cout << "Enter value of n: ";
   int n;
   cin >> n;
   for(int i = 0; i < str.size()-n+1; ++i) {
       for(int j = 0; j < n; ++j) {
           cout << str[i+j];
       }
       cout << " ";
   }
   cout << endl;
   return 0;
}

Enter value of n: 3 ACG CGT GTG TGT Process exited after .949 seconds with return ualue Press any key to continue - - -

Add a comment
Know the answer?
Add Answer to:
Q)Supposed we have a string seq= "ACGTGT" . Given a value n, find all posible outcomes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python function make_triangle(trianglechar, triangleheight) that will return a string with an isosceles right triangle...

    Write a Python function make_triangle(trianglechar, triangleheight) that will return a string with an isosceles right triangle based on the two formal parameters triangle_height giving the triangle height and triangle_char that gives the symbol to be printed. Important notes: This program returns (not prints!) a string. For this function and the other part of this lab you are required to put in a docstring. That will be checked by a TA/grader reading the program. Every one of the occurrences of triangle_char...

  • Short Answer Given the following class declaration for a binary string/integer pair (the binary n...

    ANSWER IN C++ Constructors Short Answer Given the following class declaration for a binary string/integer pair (the binary number, in the form of a string. should be the binary form of the integer): class binint public: int num; // Note this is an address! string *bin; // Note that this is an address! binint (int n); binint (string s); void convertitos(int n); void convertstoi(string s); II NOTE: you do not have to do anything // with this method you can...

  • 2. This question is about processing strings 2.1 [4 marks] Given a string str, we can...

    2. This question is about processing strings 2.1 [4 marks] Given a string str, we can calculate a checksum of the string by summing up the ASCII codes of the characters in the string. For example, the checksum of a string "apple" is 530, which equals to 'a' + 'p' + 'p' + 'l' + 'e' = 97 + 112 + 112 + 108 + 101. Write a function int calculate_checksum(char str[] that calculates and returns the checksum of the...

  • Find number list that is n%6 = 0 given list is integer 0 to n. You...

    Find number list that is n%6 = 0 given list is integer 0 to n. You can only use three function. addOne(), isOdd(), isEven(). For example, if n = 13 input list is 1 2 3 4 5 6 7 8 9 10 11 12. Output list is 6, 12. It is easy with mod operator, but I cannot use it. We can only use addOne(), isOdd(), isEven().

  • Write a function that, given a word and a set of characters, filters all occurrences of...

    Write a function that, given a word and a set of characters, filters all occurrences of those characters from the word. For e.g. remove_chars("abcdeeeeefmnop", "ebo") returns: acdfmnp i.e all occurrences of e, b and o have been removed from abcdeeeeefmnop You should acquire the word and set of characters both from the user and then pass them to the function. Note: std::cin terminates when it encounters a space, you should take the word and character set as separate inputs: std::cin...

  • Program this in C There is a lot of sorting algorithms. So far, we have covered...

    Program this in C There is a lot of sorting algorithms. So far, we have covered selection and insertion sort. However, we only covered how selection sort is implemented using an array. Every sorting algorithm implemented using an array can also be implemented using a linked list. In this assignment, you will implement the selection sort algorithm using a linked list instead of an array. You will first create an interface for handling string items. Basically, you will need to...

  • c++ 1) String format checker A string is referred to as A"B"A" if it contains n...

    c++ 1) String format checker A string is referred to as A"B"A" if it contains n > 0 consecutive As followed by n consecutive Bs followed by n consecutive As. Your task is to accept an arbitrary string of any length 1 <k, and determine if it is of the form A"B"A" If it is, then the output of the program is be "Format is OK". Otherwise the output is "Format not acceptable." For example, The given the Linux prompt>...

  • [10 marks] Assume that we have two decimal positive numbers A and B. Both numbers have n digits. ...

    [10 marks] Assume that we have two decimal positive numbers A and B. Both numbers have n digits. We want to know what is the minimum number of swaps that we need in order to get from number A to B, where in each swap we choose two digits of a number and simply swap them For simplicity, we assume that A and B do not have the digit 0 in them, and that A and B have the set...

  • The Asc function in VB takes a character and return an integer that represents that character. It does not matter what the integer representing the character actually is, but what matters is this: Asc...

    The Asc function in VB takes a character and return an integer that represents that character. It does not matter what the integer representing the character actually is, but what matters is this: Asc("a") is 1 less than Asc("b"), so that: x=Asc("a") thisLetter = x+1 # thisLetter is the Asc("b") This is a powerful fact that is used in encryption techniques, so data transferred over the web is 'deciphered so it is unreadable to others. To decipher data, we take...

  • In Java All methods listed below must be public and static. If your code is using...

    In Java All methods listed below must be public and static. If your code is using a loop to modify or create a string, you need to use the StringBuilder class from the API. Keep the loops simple but also efficient. Remember that you want each loop to do only one "task" while also avoiding unnecessary traversals of the data. No additional methods are needed. However, you may write additional private helper methods, but you still need to have efficient...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT