标签:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication16 { class Program { static void Main(string[] args) { int len = 6; for (int i = -20; i < 20; i++) { int n = ConvertCircleIndex(i, len); Console.WriteLine(i + " = " + n); } Console.ReadLine(); } private static int ConvertCircleIndex(int index, int circlelen) { if (index < 0) { index = Math.Abs(index); if (index > circlelen) index = index % circlelen; index = (circlelen - index) % circlelen; } else { index = Math.Abs(index); index = index % circlelen; } return index; } } }
标签:
原文地址:http://www.cnblogs.com/plateFace/p/5627839.html