need help with logic of a pgm...
pgm is to print the following output...
This computer generated string contains ___letters:,___ _ A,_____B,
....._____Z.
This is the output.
The blanks are the count of the characters(/alphabets) that appear in the output string itself.
I mean to say the "____" needs to be filled for eg: by the count of A in the output.It should include even the A that follows the "________" and any other occurence of A.
same with the case with all characters.
Now the problem: i will cite an eg: now since Z appears in only word zero,the count of Z will be zero( because all character appear in the output atleast once).
so when the string is printed with count of Z it will print zero Z.
now Z have appeared twice in the string and hence one more iteration will occur which will cause two Z to be output..but as you can see now there is only one Z and hence another iteration will print it as one Z..by this time the count of letter N and R has changed.so further iterations.
problem is tht the program is not converging because i have to print the count in words.If it were to be printed in numbers it happens in just 2 iterations.
Please help.
pgm is to print the following output...
This computer generated string contains ___letters:,___ _ A,_____B,
....._____Z.
This is the output.
The blanks are the count of the characters(/alphabets) that appear in the output string itself.
I mean to say the "____" needs to be filled for eg: by the count of A in the output.It should include even the A that follows the "________" and any other occurence of A.
same with the case with all characters.
Now the problem: i will cite an eg: now since Z appears in only word zero,the count of Z will be zero( because all character appear in the output atleast once).
so when the string is printed with count of Z it will print zero Z.
now Z have appeared twice in the string and hence one more iteration will occur which will cause two Z to be output..but as you can see now there is only one Z and hence another iteration will print it as one Z..by this time the count of letter N and R has changed.so further iterations.
problem is tht the program is not converging because i have to print the count in words.If it were to be printed in numbers it happens in just 2 iterations.
Please help.
Comment