Skip to content

Instantly share code, notes, and snippets.

@onsah
Created October 31, 2018 20:39
Show Gist options
  • Save onsah/2993902489ff555952d3605f4956c8ec to your computer and use it in GitHub Desktop.
Save onsah/2993902489ff555952d3605f4956c8ec to your computer and use it in GitHub Desktop.
Ödev
#include <stdio.h>
void print_pairs(const char *nucleotides, int len)
{
int count = 0;
for (int i = 0; i < len; ++i) {
if (nucleotides[i] == nucleotides[i + 1]) {
count += 1;
printf("%c%c\n", nucleotides[i], nucleotides[i]);
}
}
printf("%i consecutive nucleobases\n", count);
}
int main()
{
char nucleotides[1000];
int len;
scanf("%d", &len);
scanf("%s", nucleotides);
print_pairs(nucleotides, len);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment