用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
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); } } } }
while(true)
{
if(i==0)
i++;
else if(i==10)
i--;
}
int i = 0;
bool isup = true;
while (true)
{
if (isup)
{
i++;
}
else
{
i--;
} if (i == 10)
{
isup = false;
}
if (i == 0)
{
isup = true;
}
}
for( int i = 0; i < 100; i++ ) //++ -- 一百次
{
for( int j = 0; j < 11; j++ ) // 从零到10
{
if( (i & 1) == 0 ) x++; // i是偶数时++
else x-- // i 是奇数时--
}
}
int i=0;
bool plus=true;
while(true)
{
if(plus)
i++;
else
i--;
if(i==0||i==10)
plus=!plus;
}
for (int i = 0; i <= 10; i++)
{
if(i==10)
{
for(int j=10;j>=0;j--)
{
}
i = 0;
}
}
{
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);
}
}
有什么作用?
Dim i As Int32 = 0
While True
If i = 0 Or i = 10 Then
x = x * -1
End If
i = i + x
End While
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);
}
}
}
}