using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 时间复杂度
{
class Program
{
static void Main(string[] args)
{
int count = 0;
int x = 10; /*n>1*/
int y = 0;
while (y < x)
{
y = y + 1;
count++;
}
Console.WriteLine("时间复杂度T({0})=O({1})", x, count);
count = 0;
for (int i = 0; i < 20; ++i)
{
for (int j = 0; j < 20; ++j)
{
count++;
}
}
Console.WriteLine("时间复杂度T({0})=O({1})", 20, count);
count = 0;
x = 10; /*n>1*/
y = 0;
while (x >= (y + 1) * (y + 1))
{
y = y + 1;
count++;
}
Console.WriteLine("时间复杂度T({0})=O({1})", 10, count);
Console.ReadKey();
}
}
}
时间复杂度
最新推荐文章于 2023-07-24 10:47:15 发布