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
How many program bind in one module....
What is the purpose of record level identifier?
what is kids-rpg?
what is a rpg?
can you debug ile rpg program using isdb?
how do I declare a minor?
which program rpg or cl is efficent to update a transaction onto a database file and why ?
what is *place and *auto keyword in prtf ?plz explain
what do you mean by an input subfile, what are the keywords required?
How do u design a physical file, when you have 2 Unique fields like for eg in A student file student ID and student examination no both are unique
We have job which is running as batch. It takes atleast 06 hours to complete tht job. But I wanna do tht job with in 3 hours?
What is the difference between copybooks and subprocedures in as400?
How to write record if no field or the field are different in physical file in rpgle ?
Interviewer asked me write down DDS for load all subfile .can anybody write dds
what is data area and how it is used in rpg program ?