文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>学习笔记 2 数组

学习笔记 2 数组

时间:2010-07-23  来源:lipingren

这是一道很简单很简单的题目,发现不管学习哪种语言,只要掌握了它的语法和格式就行了,和设计程序的思维方法没多大关系。。   题目 :找出数组中最大的一个值对应的下标    

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

namespace searchmax
{
    class fmax
    {
        public static void find(int[] AA)//非静态的字段、方法或属性“searchmax.fmax.find(int[])”要求对象引用


        {
            int i,k,max;
            k = 0;
            max = AA[0];
            for (i = 0; i < 5; i++)
            {
                if (max < AA[i])
                {
                    k = i;
                    max = AA[i];
                }
            }
            Console.WriteLine("最大元素下标为{0}",k);
        }
        static void Main(string[] args)
        {
            int [] AA = {5,15,36,15,35};
            
           
            find(AA);

        }
    }
}


这里出现个问题,为什么不给k赋初值,程序就会报错?是和它存在在静态方法中有关么???
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载