110,535
社区成员
发帖
与我相关
我的任务
分享
namespace 广告算法
{
class Program
{
public static List<guanggao> listgg = new List<guanggao>();
static void Main(string[] args)
{
listgg.Add(new guanggao("A", 4, "正在播放A"));
listgg.Add(new guanggao("B", 6, "正在播放B"));
listgg.Add(new guanggao("C", 2, "正在播放C"));
listgg.Add(new guanggao("D", 1, "正在播放D"));
for (int i = 0; i < listgg.Count; i++)
{
Console.WriteLine(listgg[i].lei + ":" + listgg[i].cishu);
}
//取最小数:
int temp = 0;
for (int i = 0; i < listgg.Count; i++)
{
if ((i + 1) < listgg.Count)
{
if (listgg[i].cishu > listgg[i + 1].cishu)
{
temp = listgg[i + 1].cishu;
}
}
}
Console.WriteLine("最小数:" + temp.ToString());
//取最大数:
int m = 0;
for (int i = 0; i < listgg.Count; i++)
{
if ((i + 1) < listgg.Count)
{
if (listgg[i].cishu < listgg[i + 1].cishu)
{
m = listgg[i + 1].cishu;
}
}
}
Console.WriteLine("最大数:"+m.ToString());
Console.WriteLine("下面开始展示:");
//int y = listgg.Count;
//do
//{
// for (int i = 0; i < y; i++)
// {
// if (listgg[i].cishu > temp-1)
// {
// Console.WriteLine(listgg[i].picture);
// Thread.Sleep(2000);
// }
// }
// Console.WriteLine("\n\n");
// y -= 1;
//} while (y>=temp);
//for (int j = 0; j < m; j++)
//{
// for (int i = 0; i < listgg.Count; i++)
// {
// if (listgg[i].cishu > temp-1)
// {
// Console.WriteLine(listgg[i].picture);
// Thread.Sleep(2000);
// }
// }
// Console.WriteLine("\n\n");
//}
int y = listgg.Count;
do
{
for (int i = 0; i < y; i++)
{
if (listgg[i].cishu > temp-1)
{
Console.WriteLine(listgg[i].picture);
Thread.Sleep(2000);
}
}
Console.WriteLine("\n\n");
y -= 1;
m-=1;
} while (m>0);
Console.WriteLine("播放结束......\n");
Console.ReadKey();
}
}
class guanggao
{
public string lei { get; set; }
public int cishu { get; set; }
public string picture { get; set; }
public guanggao(string l,int c,string p)
{
lei = l; cishu = c; picture = p;
}
}
}