#include#include #include typedef struct compressed{ int a; char c; }compressed; int main() { int i = 0,j =0,count=0; compressed *com = (compressed*)malloc(10*sizeof(compressed)); char *string = "AAABBCGGAA";// Your test string hear while(i<strlen(string)) { if(string[i]==string[i+1])++count; else{ com[j].c=string[i],com[j].a = count+1; ++j,count=0; } ++i; } for(i=0;i<j;++i) { printf("%d{%c}",com[i].a,com[i].c); } return 0; }
No comments:
Post a Comment