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 diff bw PF/LF Name and their Record format name? what is restriction in record format then file name?
what is the rpg system?
What is the difference between iter and do?
what is an online rpg?
What is difference between bind by copy and bind by reference?
What is the difference between copybooks and subprocedures in as400?
write an RPG program to calculate the marks of 5 students (A,B, C, D, E)in 3 different subjects (eng, math, sci) an display on the screen
what is program status data structure?
How to declare the pull button in AS/400..
how do I play {insert rpg system here}?
how do I declare a table or array in rpg iv?
what is the use of sflnxtchg?
what is the difference between do while and do until?
what do you mean by an input subfile, what are the keywords required?
how can you display specific subfile page on the screen in unequal subfile?