Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- static string F(string X)
- {
- if (X.Length > 1)
- {
- string T = X.Substring(1);
- switch (X.Substring(0,1))
- {
- case "0":
- return T;
- case "1":
- return F(T) + '0' + F(T);
- default:
- return F(X);
- }
- }
- else
- {
- return (F(X));
- }
- }
- public static void Main(string[] args)
- {
- while (true)
- {
- Console.Write("X=");
- Console.WriteLine("F(x)=" + F(Console.ReadLine()));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment