1.find most occurrences of a character.
for exm: input:aaabbbbdddddyyy
output: d 5 times
how can i get that?
Answer Posted / sagar wagh
Dcl-S inputString Char(30) Inz('aaabbbbdddddyyy');
Dcl-S charCount Int(10);
Dcl-S maxCount Int(10) Inz(0);
Dcl-S maxChar Char(1);
Dcl-S i Int(10);
Dcl-S j Int(10);
For i = 1 to %Len(%TrimR(inputString));
charCount = 0;
For j = 1 to %Len(%TrimR(inputString));
If %Subst(inputString: j: 1) = %Subst(inputString: i: 1);
charCount += 1;
EndIf;
EndFor;
If charCount > maxCount;
maxCount = charCount;
maxChar = %Subst(inputString: i: 1);
EndIf;
EndFor;
Dsply ('Character ' + maxChar + ' occurs ' + %Char(maxCount) + ' times');
*InLR = *On;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is the use of sflnxtchg?
what is data area and how it is used in rpg program ?
do you use message subfiles? What are the necessary keywords required coding a message subfile?
how do I declare a minor?
What is ment by record level identifier?
during execution, an rpg/400 program automatically follows a sequence of operations for each record that is processed. The built-in program cycle includes the following logical steps.
How to select highest score of each subject or how to select highest income of every month?
Hi Viewers can any body explain me how to update and ahange the already existed data in physical file using subfile ? please explain me with the code if possible?
what is an online rpg?
how can I tell when to replace the array?
what is the rpg system?
how do you use commitment control in rpg?
What is the difference between copybooks and subprocedures in as400?
Assume 2 users are using the same file and first user updates some record in the file. Will the 2nd user will be able to see the updated record or not?
What is difference between bind by copy and bind by reference?