C#设计-5-数组和循环

版权声明:本博客所有内容以学习、研究和分享为主,如需转载,请联系本人,标明作者和出处,谢谢! https://blog.csdn.net/qq_33869371/article/details/83118744

数组和循环

只要用的恰当,顺序、分支、循环能够解决人类一切难题

1、数组

概念:数据的集合

1、用C#编程实现,斐波那契数列:1 1  2 3 5 8 13 .....,打印显示

2、循环(for,while, foreach,do while)

3、如何生成一组随机数据?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[50];
            var e =new Random();
            for (int i = 0; i < 10; i++)
            { a[i]=e.Next(1,10);
            }

            for (int i = 0; i < 10; i++)
            { Console.WriteLine(a[i]);
            }
            Console.ReadLine();

        }
    }
}

4、数组求和

5、如何查找数组中的最大数?

6、如何查找数组中某个数存在?

7、排序问题(选择排序)

8、解决 1/2+2/3+3/4........+99/100?

9、C#预处理指令(#region ,  # endregion)

continue: 符合条件,执行continue,不执行后面语句

break: 符合条件,跳出当前循环

猜你喜欢

转载自blog.csdn.net/qq_33869371/article/details/83118744
今日推荐