| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 616 人关注过本帖
标题:C#菜鸟问题求助
只看楼主 加入收藏
fish1985
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-8-21
收藏
 问题点数:0 回复次数:5 
C#菜鸟问题求助

Question:Input a array A with N numbers,where N>1 and N could be very large(more than 1000)
Then search the largest and smallest item in the array.

The following is what I did for searching the largest and smallest item in the array:
public static void CompareArrayElement(int [] array, int n)
{
int MaxValue=array[0];
int MinValue=array[0];


for(int index=0;index<n-1;index++)
{
if(array[index]<MinValue)
array[index]=MinValue;

// return MinValue;
else
if(array[index]>MaxValue)
array[index]=MaxValue;
// return MaxValue;
else continue;

}
Console.WriteLine("MaxValue="+MaxValue);
Console.WriteLine("MinValue="+MinValue);


}

My problem is how to input so large number of items in the array.Due to the huge number,I cannot fill the array manually.
我朋友告诉我说用参数传递,请问该怎么做?
谢谢.

搜索更多相关主题的帖子: void searching following numbers public 
2006-08-21 15:07
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 


for(int index=0;index<n-1;index++)
{
if(array[index]<MinValue)
MinValue=array[index];

// return MinValue;
else
if(array[index]>MaxValue)
MaxValuearray[index];
// return MaxValue;
else continue;

}

fill the array,
do it like this,

function fillarray(int n)
{
int[] m_arr=new int[n];
for(int i=0;i<5;i++)
{
m_arr[i]=一個隨機數;
}
}


[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-08-21 18:13
yjf518899
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-8-14
收藏
得分:0 
[QUOTE]
function fillarray(int n)
{
int[] m_arr=new int[n];
for(int i=0;i<5;i++)
{
m_arr[i]=一個隨機數;
}
}
[/QUOTE]
C#中好像没有function这个关键字吧??

If you think you can ,you can!
2006-08-21 20:57
小海龟
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1068
专家分:4
注 册:2006-8-1
收藏
得分:0 

你看看http://www.bc-cn.net/bbs/dispbbs.asp?boardID=117&ID=85431&page=1的一些例子吧,对你也许会有些帮助。


[bc09] 犯强汉者,虽远比诛!
2006-08-22 11:16
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 
看得明白 知道意思不就好了
還在乎function有沒有

不然偽代碼還有存在得意義麼

[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-08-22 12:45
fish1985
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-8-21
收藏
得分:0 

谢谢大家,此问题已解决.

2006-08-22 21:46
快速回复:C#菜鸟问题求助
数据加载中...
 
   



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

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