注册 登录
编程论坛 C# 论坛

老师帮忙 解题 如何方法中引用数组

chen1jing1 发布于 2014-02-22 14:26, 494 次点击
public static int Paixu( int shuzu)
        {
            
        for (int a=0;a<shuzu.Length ;a++ )
            {
            int zuida;
            zuida = shuzu[0];
                if (zuida < shuzu[a])
                {
                    zuida = shuzu[a];
                }
            }
        return zuida;
        }
        
        static void Main(string[] args)
        {
            int[] shuzu = new int[5];
            for (int a=0;a<shuzu.Length ;a++ )
            {
                Console.WriteLine("请输入数值");
                shuzu[a] = Convert.ToInt32(Console.ReadLine());
            }
            int _zuida =zuida;
            Console.WriteLine("最大数值为{0}",_zuida);
4 回复
#2
wp2319572014-02-22 14:40
你想问啥  或者你想实现啥功能
#3
wp2319572014-02-22 15:02
是这个意思吗
程序代码:
public static int Paixu(int[] shuzu)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cjt2
{
    class Program
    {
        public static int Paixu(int[] shuzu)
        {
            int zuida=0;

            for (int a = 0; a < shuzu.Length; a++)
            {
               
                if (zuida < shuzu[a])
                {
                    zuida = shuzu[a];
                }
            }
            return zuida;
        }

        static void Main(string[] args)
        {
            int[] shuzu = new int[5];
            shuzu[0] = 9;
            shuzu[1] = 19;
            shuzu[2] = 98;
            shuzu[3] = 29;
            shuzu[4] = 93;
            Console.WriteLine("最大数值为{0}",Paixu(shuzu));



        }
    }
}

#4
chen1jing12014-02-23 09:48
谢谢   真的 感谢    原来  调用数组是这样写的  谢谢 哈   我看的 视频中没有这个所以问的 谢谢你哈
#5
做好每一天2014-02-24 21:54
1