标签:
一 网络骗术抽奖大揭秘
下面的程序为要从 刘德华","周润发","周星驰","周杰伦","周杰","那英","刘欢 抽取一人获得某项奖品,正常的抽奖方式应为程序一方式;不正当
抽奖程序(一)公正的程序设置:
static void Main(string[] args)
{ //抽奖程序
string[] xingming=new string[7]{"刘德华","周润发","周星驰","周杰伦","周杰","那英","刘欢"};//如果你参与抽奖确保此处有你的名字;
string[] jiangpin = new string[6]{"冰箱","手机","电脑","房子","汽车","别墅"};
Random a = new Random();
int b = a.Next(xingming.Length);
Random c = new Random();
int d = c.Next(jiangpin.Length);
for (int i = 0; i < 7; i++)
{
Console.WriteLine(xingming[i]); //此处for循环 只是为了设置屏幕显示效果;
System.Threading.Thread.Sleep(500);//滚动停留500毫秒;
Console.Clear();//滚动清屏;
}
Console.WriteLine("恭喜" + xingming[b] + "获得" + jiangpin[d] + "大奖");//此处是关键位置,设置必须为xingming[];这样才能保证抽奖的公正性;
抽奖程序(二) 设置某人获得某项奖品
//抽奖程序
string[] xingming=new string[7]{"刘德华","周润发","周星驰","周杰伦","周杰","那英","刘欢"};//如果你参与抽奖确保此处有你的名字;
string[] jiangpin = new string[6]{"冰箱","手机","电脑","房子","汽车","别墅"};
Random a = new Random();
int b = a.Next(xingming.Length);
Random c = new Random();
int d = c.Next(jiangpin.Length);
for (int i = 0; i < 7; i++)
{
for(int j=0;j<6;j++)
Console.WriteLine(xingming[i] + jiangpin[j]); //此处for循环 只是为了设置屏幕显示效果;
System.Threading.Thread.Sleep(500);//滚动停留500毫秒;
Console.Clear();//滚动清屏;
}
● Console.WriteLine("恭喜" + xingming[2] + "获得" + jiangpin[5] + "大奖");//此处是关键位置,设置必须为xingming[];这样才能保证抽奖的公正性;
//如果如上设置无论前面怎么设置最后输出的都是周星驰获得别墅;
程序(三)设定某些人中奖
//抽奖程序
string[] xingming=new string[7]{"刘德华","周润发","周星驰","周杰伦","周杰","那英","刘欢"};//如果你参与抽奖确保此处有你的名字;
string[] jiangpin = new string[6]{"冰箱","手机","电脑","房子","汽车","别墅"};
Random a = new Random();
● int b = a.Next(3);//制定某些人获奖;
Random c = new Random();
int d = c.Next(jiangpin.Length);
for (int w = 1; w <= 2; w++)
{
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 6; j++)
Console.WriteLine(xingming[i] + jiangpin[j]); //此处for循环 只是为了设置屏幕显示效果;
System.Threading.Thread.Sleep(500);//滚动停留500毫秒;
Console.Clear();//滚动清屏;
}
}
Console.WriteLine("恭喜" + xingming[b] + "获得" + jiangpin[d] + "大奖");//此处是关键位置,设置必须为xingming[];这样才能保证抽奖的公正性;
//如果如上设置无论前面怎么设置最后输出的都是周星驰获得别墅;
综上各位不要相信各种网络抽奖,上当受骗的几率很大!!
二 小型自动统计程序
:平均值 最大值(相关球员) 最小值(相关球员) 求和;
Console.WriteLine(" 记录球员成绩 ");
int[] cj = new int[6];
for (int i = 0; i < cj.Length; i++)
{
Console.WriteLine("请输入第" + (i + 1) + "个球员的成绩");
cj[i] = Convert.ToInt32(Console.ReadLine());
}
int min = 100000, max = 0, j = 0, z = 0, av = 0, h = cj.Length, s = cj.Length;
for (j = 0; j < cj.Length; j++)
{ //通过这个for,可以计算所有值
if (cj[j] > max)
{
max = cj[j];
h = j;
}
if (cj[j] < min)
{
min = cj[j];
s = j;
}
z = z + cj[j];
}
Console.WriteLine("最大" + max + "最小" + min + "总分" + z + "平均分" + (z / cj.Length));
Console.WriteLine("成绩最好的球员" + (h + 1) + "成绩最差的球员" + (s + 1));
标签:
原文地址:http://www.cnblogs.com/woniu-net/p/4489559.html