Question #44966

In the Byteland country a string "S" is said to super ascii string if and only if count of each character in the string is equal
to its ascii value.
In the Byteland country ascii code of 'a' is 1, 'b' is 2 ...'z' is 26.
Any string "S" can be converted to super ascii string by performing operations like addition or removal of a character.
Your task is to find out the minimum number of operations required to convert the string to super ascii string.

Expert's answer

Answer on Question #44966, Engineering, Other

Task:

In the Byteland country a string "S" is said to super ascii string if and only if count of each character in the string is equal to its ascii value. In the Byteland country ascii code of 'a' is 1, 'b' is 2 ...'z' is 26. Any string "S" can be converted to super ascii string by performing operations like addition or removal of a character. Your task is to find out the minimum number of operations required to convert the string to super ascii string.

Answer:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int T,i,j,k,count=0,inc=0;
char str1[10][100];
printf("number of test cases");
scanf("%d",&T);
for(i=0;i<t;i++) 1="" 2;="" 3;="" 4;="" 5;="" for(i="0;i<T;i++)" for(j="0;str1[i][j];j++)" i="0;" i<t;i++)="" if(str1[i][j])="" inc++;="" j="k;" j;ek;="" {="" }="" }```c
if(str1[i][j]) =& str1[i][k]) {
inc++;
j=k;
}
}
if(inc < (str1[i][j]-96)) : (str1[i][j]-96-inc);
inc = 0;
}
printf("Count for %s is %d\n",str1[i],count);
count = 0;
} return 0;
}


http://www.AssignmentExpert.com/</t;i++)></string.h></stdlib.h></stdio.h>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS