C++ :: Switch DNA Strand - From Array To Complementary
Jan 25, 2015
How do I convert dna from an array to complementary dna.
void print_reverse_complement(const char dna[]) {
the above function will convert DNA to Complementary DNA.. i.e A=T, C =G, G=C and T=A.
The prompt should look like: (asks user for dna sequence and stores into array) (prints back entered sequence)DNA sequence: ATCGGCATA DNA complement: TAGCCGTAT DNA reverse complement: TATGCCGAT
Then how would I do the same thing, but this time the reverse complement?
I am trying to make a program which manages the data of 5 different patients (its an uni assignment), and i want to use a switch case as a menu to switch between the patients. All other functions (as for example putting the infromation on a file) work, but i cant figure out to bring the switch to work. First it asks for the number of the patient which should be worked with, this works perfectly, but afterwards changiung between the persons doesnt work as thought. It should ask everytime after it switches to one patient (i removed some functions to make it easier to read) and then asks to which it should jump next. If i put the number of one case (lets say 3) it just stops the program.
********Example: user@pc ~/wherever $ ./program current variables: jo = 2 a = 0 1 //the entered number The variable a = 1 patient 1 Enter the number of the next patient2 // and then it closes **************
The same thing happens if i compile an example code from a book, it writes the first case and then stops.
I looked already through the forum but didnt find a person with a similar problem, maybe i didnt dig deep enough.
I am running Linux Mint 17 and use gcc as compiler.
Code:
include <stdio.h> #include <stdlib.h> int a=0; int jo=2; int main(void){ printf("current variables: jo = %d a = %d
so I am trying to have an switch statement array. but every time i complete a case statement the whole process is returned. the thing is i want the menu to stay up even if i complete the case.
I have tried to search all about strings,I have the occurrences and have worked out what letter corresponds with which. I have searched that much i can remove the vowels and reverse my string but I dont know how to swap them. This is what i have this far. When it compiles it just prints the decipher is:
If i even find out am i on the right track ive used caps when swapping to try and stop the doubles over writing,...
#include<stdio.h> #include<string.h> int main(void){ int i,count=0; char secretText[] = "lopsy, hssepokd wl okrhsowk:
I have a seat allocation algorithm for an airplane 30 x 6 seats. The plane is 'split' front (1 - 15) and back (16 -30), right (A,B,C) and left (D,E,F). I am placing passengers in window seats front right centre (15A) first then back left centre (16F) followed by (15F) followed by (16A). This will continue for single passengers middle seats then aisle.
Another part of the algorithm is to ensure parties >2 or <=6 to sit together in an empty row, if not possible the party will be split as to not have a person in the party sitting alone firstly. i.e. 6 is 3 + 3 or 2 + 2 + 2 or 4 + 2 or 3 + 2 + 1 or 4 + 1 + 1 or 3 + 1 + 1 + 1 and so.
I have got it working for one person but seating two people is a bit more difficult. I am trying to get 15A,15B then 16E,16F then 16A,16B then 15E,15F then 16C 16D and 15C 15D.
This code only allocates passengers 15 A 15B then 15C 15D then 15E 15F
//seat allocation for two people public bool[,] seatTwoPerson(bool[,] seatArray, int startCol, int endCol, int directionX, int startRow, int endRow, int directionY) { //loop through seatArray section determined by parameters //for (int col = startCol; directionX < 0 ? col >= endCol : col < endCol; col += directionX)
Just making typical console game where hero moves with w a s d.
However, in my code, while a and w work (minusing), s and d dont work (adding). I have used a switch statement to change the char position of the hero based on kbhit.When you hit s or d, the buttons that add 1 to the 2nd dimension of the array, the screen goes crazy!
#include <iostream> #include <string> #include <conio.h> #include <ctime> #include <cstdlib> using namespace std; const char PLAYER = 'H';
I want to make something like some users using the same machine so they need to be registered to the system and the their id something like this (H510698541) and their information should appear on the screen.
okay so like case 2 and 3 is not working, also the program is still not finish but why isn't case 2 and 3 not functioning well on the switch part? case 1 works just fine
Code: #include<stdio.h> main () { //passcode part (passcode is 1234)
I'm currently doing a project which will trigger an alarm and light up an LED when a character 'E' is detected from a bluetooth input. I'm supposed to program a pic18f4525 board.
I'm having troubles with where to start on the codes to enable the LED to light up upon detection of character 'E'. I'm using ports RD0-RD3. This is how I initialised them in the main loop.
Code: TRISD = 0b11000000; PORTD = 0xC0;
Am I doing the initialising right? Also, how to program it to light up when the character's detected?
Switch case statements are a substitute for long if statements that compare a variable to several "integral" values ("integral" values are simply values that can be expressed as an integer, such as the value of a char).
So does that mean switch statements can only test if variable == value and nothing more, like > < >= <= != etc... ? I tried to make a program to test this and it seems like switch statements are limited to == but I'm not sure, maybe I'm doing something wrong.
This is the program I tried to make to test this:
Code: #include <stdio.h> int main () { int n;
[Code]....
So is it true that switch statements only work with the built in == operator? if that was the case then I would feel rather meh about switch statements.
I'm making a game in OpenGL GLUT. A ball is going to move forwards along the Z axis and hit a wall. I want to be able to move the ball left and right, up and down before firing it off on the Z axis. I'm using glutSpecialKeys for this, and I've got everything set up, but I'm not sure how I use it with a switch statement? Here is a snippet of code:
void Special_Keys (int key, int x, int y){ switch(key){ case GLUT_KEY_UP: //do something break; case GLUT_KEY_DOWN: //do something
[Code] .....
Where the comment is saying "do something", I'm not sure what I actually need to do? Is it a method or what?
Please select: 1 - Year 2 - Day 3 - Month Input choice: 1 Input Number: 2 I'm a Sophomore!
Please select: 1 - Year 2 - Day 3 - Month Input choice: 2 Input Number: 2 It's Tuesday.
Please select: 1 - Year 2 - Day 3 - Month Input choice: 3 Input Number: 2 February. Heart's month!
Here is my code, I only typed the Year(levels) yet because when I tried to input 2(day) and 3(month) for the Input choice and after that, Inputting a number to 1-4 would yield the same result to case 1's year levels.
#include <stdio.h> #include <conio.h> using namespace std;
[Code].....
how to link the case 2 to days and case 3 to months?
I am using a switch statement as a menu. If I enter a non-integer value as my choice, I expect the error message , "Invalid entry", to display but instead the output keeps running.
The error ive been getting with this code is after i go to the check out option, enter the data then click (ctrl + z). Then program glitches back and forth from the menu to the check out option continuously and im not entirely sure why.
Heres my code:
[#include <iostream> #include <windows.h> #include <iomanip> #include <fstream> using namespace std; void records(){ cout << setw(10) << "Ministry of Health Hospital System
While running a Doc/View SDI, is there any way to switch from text mode to rtf mode during runtime? Search reveals nothing.
Say I have an editor and I want the app to use text, I can set the ctor as follows.
Code:
CEditorDoc::CEditorDoc() { // TODO: add one-time construction code here m_bRTF = FALSE; }
But once I've done that and compiled the app, while it's running, is there a way for the user (or programmer) to change the mode back to RTF? One solution that occurred to me is to use 2 document classes, but that's a hassle.
OverLay[0]=ini_read_string(map_file_ini,_T("Section"),_T("Key"),_T("NULL")); if(OverLay[0]==_T("NULL"))MessageBox(NULL,_T("File or kay not exists"),_T("Error"),MB_ICONEXCLAMATION|MB_OK);
but the key dos not exists, so it will return NULL, but yet i am not getting the message box (LPCWSTR) i also dit try
and ther it is, an message box with the text "NULL" so why is the if(OverLay[0]==xxx) not working? and i also need a big list so an working switch(OverLay[0]) will be nice as well (else i need to do if/ else if many times)
I was getting errors and I looked into the error and it told me to fix it by adding Code: { } in my case statements. I did, it compiled but fell through the whole thing. Lets say I enter 1, it outputs the was not found 5 times in a row.
Code: void addressbook::EditNameOrDate() { std::cout << "Enter 1 to Edit the contacts First Name: " << " "; std::cout << "Enter 2 to Edit the contacts Last Name: " << " "; std::cout << "Enter 3 to Edit the contacts Street Address: " << "
How to do i fix this code im not good at using function, im trying to pass a statement from switch to my double passengersR i always come out with a error
this output: Name passenger: Enter number passenger: Choose from A to D if choose A Total Regular Passenger: 6.19624e-312
did i do something wrong im not really good at function and im trying to learn how to pass switch to void function
Code:
#include<conio.h> #include <iostream> #include <Iomanip> #include <string> using namespace std; double passengersR () { double m;
I pretty much got the assignment done. All it asked for was that you make a C program that displays which manufacturer owned a disk drive based on the code entered. Pretty simple. Just enter 1, 2, 3, or 4 and get the associated manufacturer. Though I am trying to implement an error messege to it for any interger that isn't 1-4.
Code: #include <stdio.h> int main() {
[Code]...
o errors are given and it works fine as long as you enter 1-4, but when you enter any other didgit it just stops the program without any messeges.
Ran into something today that does not make sense:
This compiles: Code: int x = 5;
switch(x) { case 0: { int value = 5; } break;
[Code] ....
Ok so it doesn't like int value = 6 b/c of int value = 5 for case 0. However since the value in case 0 is declared within the brackets one would think it has case scope.
So I tried this:
Code: int x = 5; switch(x) { case 0: { int value = 5; } break;
[Code] ....
Now it doesn't like it b/c value has not been declared in case 1:. These two conditions cannot possibly be both true at the same time. You cannot disallow the declaration of value in case 1 b/c it interferes with value in case 0 and at the same time disallow me to use value from case 0 b/c it is not in scope. If it was not in scope then theoretically I should be able to declare value in case 1.
Both MSVS 2012 and 2013 exhibit the same behavior. I checked the standard and it is unclear on the matter.