2nd
#include<iostream>
#include<vector>
using namespace std;
int  main()
{
    string s;
    cin>>s;
    int i=0,count=1;
    vector<int> no;
    vector<char> c;
    while(s[i]!='\0')
    {
        if(s[i]==s[i+1])
        count++;
        else
        {
            c.push_back(s[i]);
            no.push_back(count);
            count=1;
        }
        i++;
    }
    for(i=0;i<c.size();i++)
    cout<<c[i]<<no[i];
    return 0;
}


On Sat, Sep 24, 2011 at 5:53 PM, Kunal Yadav <kunalyada...@gmail.com> wrote:

> for 1st
> #include<iostream>
> #include<vector>
>
> using namespace std;
> int  main()
> {
>     char c;
>     string s;
>     int n;
>     vector <char> ans;
>     cin>>s;
>     int i=0;
>     while(s[i]!='\0')
>     {
>         c=s[i];
>         n=s[i+1]-'0';
>         while(n--)
>         ans.push_back(c);
>         i+=2;
>     }
>     for(i=0;i<ans.size();i++)
>     cout<<ans[i];
>     return 0;
> }
>
>
> On Thu, Sep 22, 2011 at 3:46 PM, Dheeraj Sharma <
> dheerajsharma1...@gmail.com> wrote:
>
>> for 1st
>>
>> #include<iostream>
>> #include<conio.h>
>> #include<string.h>
>>
>> using namespace std;
>> int main()
>> {
>>     char str[100];
>>     cin>>str;
>>     int len=strlen(str);
>>     int i=1;
>>     while(i<len)
>>     {
>>                 int x=str[i]-48;
>>                 while(x--)
>>                 cout<<str[i-1];
>>                 i+=2;
>>                 }
>>                  getch();
>>
>> }
>>
>>
>> On Thu, Sep 22, 2011 at 3:42 PM, Dheeraj Sharma <
>> dheerajsharma1...@gmail.com> wrote:
>>
>>> for 2nd one
>>> #include<iostream>
>>> #include<conio.h>
>>> using namespace std;
>>> int main()
>>> {
>>>     char str[100];
>>>     cin>>str;
>>>
>>>     char ch=str[0];
>>>     int count=0,i=0;
>>>     while(str[i])
>>>     {
>>>                  if(str[i]==ch)
>>>                  count++;
>>>                  else
>>>                  {
>>>                      cout<<ch<<count;
>>>                      ch=str[i];
>>>                      count=1;
>>>                      }
>>>                  i++;
>>>                  }
>>>                  cout<<ch<<count;
>>>                  getch();
>>>
>>> }
>>>
>>>
>>> On Thu, Sep 22, 2011 at 11:58 AM, rahul sharma 
>>> <rahul23111...@gmail.com>wrote:
>>>
>>>> i found a question of ms earlier but know i not able to find
>>>> it.....plz post link or thread ....
>>>>
>>>>
>>>> i/p::a3b2c4:
>>>> o/p:aaabbcccc
>>>>
>>>> i/p:aaabbc
>>>> o/p:a3b2c1
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>>
>>>
>>> --
>>> *Dheeraj Sharma*
>>> Comp Engg.
>>> NIT Kurukshetra
>>>
>>>
>>>
>>
>>
>> --
>> *Dheeraj Sharma*
>> Comp Engg.
>> NIT Kurukshetra
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards
> Kunal Yadav
> (http://sourcebit.in)
>
>


-- 
Regards
Kunal Yadav
(http://sourcebit.in)

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to