Jump to content

trocar letras e depois inverter uma string


troser
 Share

Recommended Posts

Eu já consegui alterar todas as letras que queria numa sequência. Depois de alteradas preciso que a sequência se inverta. Como faço isso?

O código está aqui:

#include <stdio.h>
#include <string.h>

int trocarDNA(char string[])

{
int i = 0;

while(string[i] != '\0')
{

	if(string[i] == 'A')

		string[i] = 'T';
	else if(string[i] == 'T')
			string[i] = 'A';
	else if(string[i] == 'C')
			string[i] = 'G';
	else if(string[i] == 'G')
			string[i] = 'C';
	i++;
}

return 0;

}

int main(){

char string[300]; 

int i = 0;

printf("Introduza a sequencia de DNA (maiusculas): \n");

        gets(string);

trocarDNA(string);

printf("Complemento: \n");

for(i; i<=strlen(string); i++)

	printf("%c", string[i]);

return 0;

}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.