Number Arrange in c#. [Resolved]

Posted by Suneel161 under C# on 1/31/2014 | Points: 10 | Views : 896 | Status : [Member] | Replies : 4
Hi,
i have one string i.e 1100110011.
how to align all zeros left side and ones in right side.




Responses

Posted by: Sravan661 on: 2/3/2014 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi
Revert to me if you have any questions . . .

sravan

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sravan661 on: 2/2/2014 [Member] Bronze | Points: 25

Up
0
Down
Hi suneel
Hope this helps you

 string strInput = "1100110011";
char[] ch = strInput.ToCharArray();
string strOutput = string.Empty;

foreach (char c in ch)
if (c.Equals('0'))
strOutput += c;

while (!strOutput.Length.Equals(strInput.Length))
strOutput += "1";

Console.WriteLine( strInput + "\n" + strOutput);


Please mark as answer if satisfied . . .

sravan

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Suneel161 on: 2/3/2014 [Member] Starter | Points: 25

Up
0
Down
thanks sravan..

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sravan661 on: 2/3/2014 [Member] Bronze | Points: 25

Up
0
Down
you are welcome



sravan

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response