标签:blog http io ar sp on 2014 log cti
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { double integer=0,result=0; //integer:正整数; Console.WriteLine("请输入一个正整数"); integer = Convert.ToDouble(Console.ReadLine()); do { Console.Write("第{0}次{1}------->", result, integer); if (integer % 2 == 0) integer /= 2; else integer=integer*3+1; result++; Console.WriteLine("{0}", integer); } while (integer!=1); Console.WriteLine("经过{0}次这样的运算才得到数1", result); Console.Read(); } } }
标签:blog http io ar sp on 2014 log cti
原文地址:http://blog.csdn.net/hbd0616/article/details/41144263