1,22,333,4444,55555,..........nnnnn(n个n) 
用后一个数表示前一个数,急求,谢谢啦 
用C#

解决方案 »

  1.   

      for (int i = 1; i < 10; i++)
                {
                    for (int j = 1; j <=i; j++)
                    {
                        Console.Write(i);
                    }
                    Console.WriteLine();
                }
      

  2.   

    是不是给你55555,返回4444?
            public static int previous(int x) {
                int y = 0;
                int z = x % 10 - 1;
                for (int i = 0; i < z; i++ ) {
                    y = y * 10 + 1;
                }
                return y * z;
            }
      

  3.   

     string x = "999999999";
                for (int i = x.Length; i > 0; i--)
                {
                    for (int j = 0; j < i; j++)
                    {
                        Console.Write(i);
                    }
                    Console.WriteLine();
                }
      

  4.   

    用递归:
    从头到尾:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace class_for_csdn
    {
        class Program
        {
            static void Main(string[] args)
            {
                int a =int.Parse ( Console.ReadLine());
                calculator(a);
                Console.ReadLine();
            }
            static void calculator(int n)
            {
                if (n != 1)
                    calculator(n-1);
                for (int i = 0; i < n; i++)
                    Console.Write(n);
                Console.WriteLine();
            }
        }
    }
    从尾到头:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace class_for_csdn
    {
        class Program
        {
            static void Main(string[] args)
            {
                int a =int.Parse ( Console.ReadLine());
                calculator(a);
                Console.ReadLine();
            }
            static void calculator(int n)
            {
                for (int i = 0; i < n; i++)
                    Console.Write(n);
                Console.WriteLine();
                if (n != 1)
                    calculator(n-1);
            }
        }
    }