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 a record lock error?
thanks mr.Harshad R Suryawaunshi,i'm new to as400 i think you are telling in rpgile i know only rpg400 if possible can you tell in rpg400
which program rpg or cl is efficent to update a transaction onto a database file and why ?
Suppose we have one database file and it is used by 5 programs and in 3 program we have to add some records in datbase file s what is the impact on other program?
what is an online rpg?
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 a rpg?
is this a rpg channel?
How can we know running job is batch or interactive?
how can I tell when to replace the array?
Q:Hi all,i want accurate answer with code using in built functions.please sent me code as soon as posible. I have program nmed PGM1 which '' RETRIEVE Current production date''should correctly default the production date for the user who is issuing raw materials to the manufacturing.The production date can be different from the celendra date. However, the program does not make the correct adjustment for all manufacturing plants. there is a parameter which determines the production start time e.g. 07:00 if the system time precedes this,the program subtracts one from the celendra day.This work fine when the celendar day starts after production day as it does in England,the system should be adding one to the celendar day during the overlap. unfortunately the program was desined to assumed the celendar day always starts before the production day. Change required in the program: Change the PROGRAM PGM1 to use the new parrameter to decide whether to add or subtract 1 from the celendar day when determining the production date.
how does the rpg element work?
How to create a login screen using a command instead of display file.... intention is to get a password field on a command..... how do you achieve this...
How to handle duplicate error handling in RPG?
If my rpg program has a date field, what extra care I have to take while compiling that rpg program? If the file is keyed and I have declared the file as well as key list properly in my program. Still am getting an error message like "chain/reade operation is not allowed" what may be the case?