zoukankan      html  css  js  c++  java
  • C#第十二节课

    数组

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

    namespace shuzu
    {
    class Program
    {
    static void Main(string[] args)
    {
    for (; ; )
    {

    //一维数组【相同数据类型】
    //第一种定义方式
    //int[] shuzu = new int[5];
    //for (int i = 0; i < 5; i++)
    //{
    // shuzu[i] = i + 1;
    //}
    // //索引从0开始
    // //赋值
    // //shuzu[0] = 1;
    // //shuzu[1] = 2;
    // //shuzu[2] = 3;
    // //shuzu[3] = 4;
    // //shuzu[4] = 5;
    // ////shuzu[5] = 6;
    // ////shuzu[6] = 7;
    // Console.WriteLine(shuzu[4]);


    //第二种定义方式
    //int[] shuzu = new int[] { 1,2,3,4,5 };
    //Console.WriteLine(shuzu[2]);


    //从控制台输入10个人的年龄放入数组,
    //将十个人的年龄求总和
    //int [] age=new int [10];
    //int sum = 0;
    //for (int i = 0; i < 10; i++)
    //{
    // Console.Write("请输入第"+(i+1)+"个人的年龄:");
    // age[i] = int.Parse(Console.ReadLine());
    // sum += age[i];
    //}

    //Console.WriteLine(sum);

    //输入人名放进数组,输出第5个人的姓名
    //Console.Write("请输入有几个人:");
    //int a = int.Parse(Console.ReadLine());

    //string [] name =new string [a];
    //for (int i = 0; i < a;i++ )
    //{
    // Console.Write("请输入第" + (i + 1) + "个人的姓名:");
    // name[i] = Console.ReadLine();
    //}
    //Console.WriteLine(name[4]);

    //输入班级人数,根据人数,
    //挨个输入成绩,求平均分
    //Console.Write("请输入班级人数:");
    //int a = int.Parse(Console.ReadLine());
    //double [] fen = new double [a];
    //double sum = 0;
    //for (int i = 0; i < a;i++ )
    //{
    // Console.Write("请输入第"+(i+1)+"个人的分数:");
    // fen[i] = double.Parse(Console.ReadLine());
    // sum += fen[i];
    //}

    //Console.WriteLine("班级平均分为:"+sum/a);


    //二维数组
    //int[,] shuzu = new int[3, 4];
    //int[,] shuzu = new int[,] {
    //{1,2,3,4},
    //{5,6,7,8},
    //{6,7,8,9}
    //};

    //string[,] shuzu = new string[,] {
    //{" ","■","■","■","■","■",""},
    //{" "," "," ","■","","",""},
    //{" "," "," ","■","","",""},
    //{" "," ","■","■","■","",""},
    //{" "," "," ","■"," "," ",""},
    //{" "," "," ","■"," "," ",""},
    //{"■","■","■","■","■","■","■"}
    //};

    //for (int i = 0; i < 7; i++)
    //{
    // for (int j = 0; j < 7; j++)
    // {
    // Console.Write(shuzu[i, j]);
    // }
    // Console.WriteLine();
    //}


    //输入班级人数,将每个人的
    //语文,数学,英语成绩输入二维数组
    //Console.Write("请输入班级人数:");
    //int a = int.Parse(Console.ReadLine());
    //double [,] shuzu = new double [a,3];

    //for (int i = 0; i < a; i++)
    //{
    // for (int j = 0; j < 3; j++)
    // {
    // if (j == 0)
    // {
    // Console.Write("请输入第"+(i+1)+"个人的语文成绩:");
    // }
    // if (j == 1)
    // {
    // Console.Write("请输入第" + (i + 1) + "个人的数学成绩:");
    // }
    // if (j == 2)
    // {
    // Console.Write("请输入第" + (i + 1) + "个人的英语成绩:");
    // }
    // shuzu[i, j] = double.Parse(Console.ReadLine());
    // }
    //}

    // Console.ReadLine();

    //三维数组
    //int[, ,] shuzu = new int[3, 2, 4];

    //{
    // {
    // {,,,},
    // {,,,}
    // },
    // {
    // {,,,},
    // {,,,}
    // },
    // {
    // {,,,},
    // {,,,}
    // }
    //};


    string[,] a = new string[8, 8]{
    {" "," ","||"," "," "," "," "," "},
    {" "," ","||"," "," ","//"," "," "},
    {" ","==","++","==","||","==","==","||"},
    {" "," ","||"," ","||"," "," ","||"},
    {" ","//","||","\ ","||","==","==","||"},
    {" /","/ ","||"," ","||"," "," ","||"},
    {" "," ","||"," ","||"," "," ","||"},
    {" "," ","||"," ","||","==","==","=="},

    };
    for (int i = 0; i < 8; i++)
    {
    for (int j = 0; j < 8; j++)
    {
    Console.Write(a[i,j]);
    }
    Console.WriteLine();
    }

    Console.ReadLine();

    }
    Console.ReadLine();
    }
    }
    }

  • 相关阅读:
    聊聊tcpdump与Wireshark抓包分析
    TCP三次握手与Tcpdump抓包分析过程
    grep 同时满足多个关键字和满足任意关键字
    java监听器原理理解与实现
    Linux下如何查看哪些端口处于监听状态
    netstat命令怎么查看端口是否占用
    jQuery Mobile 入门基础教程
    用U盘与移动硬盘制作WIN7启动盘(亲自实践)
    【iOS】用Layer创建一个三维模型以及拖动
    Java中的位运算符、移位运算
  • 原文地址:https://www.cnblogs.com/xiongxiaobai/p/5268941.html
Copyright © 2011-2022 走看看