| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 531 人关注过本帖
标题:代码有一处错误。请教
只看楼主 加入收藏
哈哈飞
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2007-10-31
收藏
 问题点数:0 回复次数:2 
代码有一处错误。请教
如下是Visual C#入门经典里128页的一个例子。我运行了有一个错误是“}expected”我觉得我的括号没有少啊。请问是怎么了呢?谢谢。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Ch07Ex01
{
    class Program
    {
        static void Main(string[] args)
        {
            //创建源数据组
            int[] testArray = { 4, 7, 4, 9, 7, 8, 3, 9, 1, 9 };
            int[] maxValIndices;
            int maxVal = MAXima(testArray, maxValIndices);

            Console.WriteLine("Maxinum value is {0} found at element indices;", maxVal);
            foreach (int index in maxValIndices)
            {
                Console.WriteLine(index);
            }
            

           static int Maxima(int[] integers,out int[] indices)
            {
                int maxVal=testArray[0];
                int count=1;
                int i;

                for (i=1;i<testArray.length;i++)
                {
                    if (testArray[i]>maxVal)
                    {
                        maxVal=testArray[i];
                        count=1;
                        indices=new int[1];
                        indices[0]=i;
                    }
   
                    
                    else if(testArray[i]==maxVal)
                    {
                        count++;
                        int[] temp=indices;
                        indices=new int[count];
                        temp.CopyTo(indices,0);
                        indices[count-1]=i;
                    
                    }
                           
                    return maxVal;
               
                }
            
            }
        }
     }
搜索更多相关主题的帖子: using System int 代码 MAXi 
2008-04-19 01:53
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
最后少了 一个  namespace没有关闭

女侠,约吗?
2008-04-19 02:52
ywqsa206
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2008-4-8
收藏
得分:0 
长夜漫漫,我以为我睡不着,原来野比老师也没睡呢。。呵呵。。
2008-04-19 03:00
快速回复:代码有一处错误。请教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021875 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved