Click here to Skip to main content
11,789,710 members (61,105 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: strings
given a string SSSEERRTADEEE write a program to output the following way to given string:S3E2R2T1A1D1E3

please what will be the logic to above probl C# in c#.Hope anyone must give me the waiting for your reply...
Posted 5-Feb-13 17:13pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can use the code below:

private static void GetCharCountInString()
            const string strOriginal = "SSSEERRTADEEE";
            string strNew = string.Empty;
            int index = 0;
            char[] chararray = strOriginal.ToCharArray();

            for (index = 0; index < chararray.Length; index++)
                int charCount = 1;
                int firstindex = index;
                int flag = 0;
                while (index != strOriginal.Length - 1 & flag == 0)
                    if (chararray[index].CompareTo(chararray[index + 1]) == 0)
                        flag = 0;
                        flag = 1;
                strNew += chararray[firstindex].ToString(CultureInfo.InvariantCulture) +
            Console.WriteLine("Original : {0}\n New : {1}", strOriginal, strNew);

Happy Coding Smile | :)
Aurovinda shyamal at 6-Feb-13 7:28am
Hi SruthiR
This code is working fine.Thanks for your time given....
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

string s = // ...

// ...

    s = "S3E2R2T1A1D1E3";
//... :-)

It should give you the following idea: if you provided some example of data on input and output, it does not mean you formulated the problem.

The question does not really make any sense.

Good luck,
Aurovinda shyamal at 6-Feb-13 1:36am
Hi Sergy
If you don't know the answer, please avoid,the question but don't give any negative comment about any one's question.Its my requirement..I need it... very urgent.
Sergey Alexandrovich Kryukov at 6-Feb-13 1:45am
It cannot be urgent, because you apparently don't know what you want. About negative comment... it's not even rude, just ignorant. My answer is accurate enough, you just fail to see it.
skydger at 6-Feb-13 2:21am
Fair enough.
My 5 xD
Sergey Alexandrovich Kryukov at 6-Feb-13 2:23am
Thank you. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 999
1 Maciej Los 765
2 KrunalRohit 686
3 CPallini 606
4 Richard MacCutchan 430

Advertise | Privacy | Mobile
Web04 | 2.8.1509028.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100