• 初识数组


    初识数组  

    一  网络骗术抽奖大揭秘

    下面的程序为要从 刘德华","周润发","周星驰","周杰伦","周杰","那英","刘欢 抽取一人获得某项奖品,正常的抽奖方式应为程序一方式;不正当

    抽奖程序(一)公正的程序设置:

     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));

  • 相关阅读:
    css div position to parent
    linux 解压缩/压缩命令大全
    button with backgroundimage programmaticaly
    使用数组初始化vector 对象
    AudioServicesPlaySystemSound
    objective-c 中随机数的用法 (3种:arc4random() 、random()、CCRANDOM_0_1() )
    指针和多维数组(例子需要好好消化理解)
    很经典的赋值算法之一:动态为数组有序赋值
    string 类的c_str 的成员函数
    自由存储区的空间 C++和C
  • 原文地址:https://www.cnblogs.com/woniu-net/p/4489559.html
Copyright © 2020-2023  润新知