一个数从0开始 ++  直到10
然后从10-- 直到0
再从0 ++到10
再从10 --到0
如此循环

解决方案 »

  1.   

    要一直循环下去吗??int i=0;
    while(true)
    {
        if(i==0)
            i++;
        else if(i==10)
            i--;
    }
      

  2.   

    神经病?...
    int i = 0;
    bool isup = true;
    while (true)
    {
        if (isup)
        {
            i++;
        }
        else
        {
            i--;
        }    if (i == 10)
        {
            isup = false;
        }
        if (i == 0)
        {
            isup = true;
        }
    }
      

  3.   

    int x = 0; //一个数从0开始
    for( int i = 0; i < 100; i++ ) //++ -- 一百次
    {
      for( int j = 0; j < 11; j++ ) // 从零到10
      {
        if( (i & 1) == 0 ) x++; // i是偶数时++
        else x-- // i 是奇数时--
      }
    }
      

  4.   

    我上面那个写错了,应该是
    int i=0; 
    bool plus=true;
    while(true) 

        if(plus) 
            i++; 
        else 
            i--; 
        if(i==0||i==10)
            plus=!plus;
    }
      

  5.   


    for (int i = 0; i <= 10; i++)
                {
                    if(i==10)
                    {
                        for(int j=10;j>=0;j--)
                        {
                        }
                        i = 0;
                    }
                }
      

  6.   

    private void Loop(int number,int times)
    {
     if(times==0) return;
     if(number==0)
     {
       for(int i=0;i<10;i++)
       {
        number++;
       }
       times--;
       Loop(number,times);
     }
     esle if(number==10)
     {
       for(int i=0;i<10;i++)
       {
        number--;
       }
       times--;
       Loop(number,times); 
     }
    }
    有什么作用?
      

  7.   

    用vb.net写了个,搂住看看可以用么Dim x As Int32 = -1
    Dim i As Int32 = 0
    While True
        If i = 0 Or i = 10 Then
           x = x * -1
        End If
           i = i + x
    End While
      

  8.   


    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication8
    {
        class Program
        {
            static void Main(string[] args)
            {
                int i = 0, j = -1;
                while (true)
                {
                    Console.WriteLine(i.ToString());
                    i += (i % 10 == 0) ? j = -j : j;
                    System.Threading.Thread.Sleep(300);
                }
            }
        }
    }