
Random r = new Random();
int i = ConvertToInt32(ConsoleReadLine());
if (i <= 0)
{
return;
}
dynamic i1 = i - 1;
int[] a = new int[i1 + 1];
int c;
for (c = 0; c <= i1; c++)
{
a[c] = rNext(1, i + 1);
}
for (c = 0; c <= i1; c++)
{
if (c % 5 == 0)
{
ConsoleWriteLine();
}
ConsoleWrite((a[c]ToString() + " "));
}
ConsoleReadKey();
把字符串数组变成整形数组:
string[] array_str = strNumsSplit(',');
int[] array_int = new int[ array_str Length] ;
for(int i = 0;i< array_strLength;i++)
{
array_int[i] = intParse( array_str[i]);
}
然后在下面用array_int就可以了
1、实现的代码如下。
2、打开:生成的程序(写好代码后要点击生成程序)。
3、在bin\Debug目录下exe程序为执行应用程序。
4、设置VS中字体大小点击确定。
5、行号的显示:工具--》选项,就完成了。
public int[] GetFactors(int n){
int Count = 0;
int[] temp = new int[n];
for(int i = 1; i < n; i++){
if (n % i == 0) {
temp [Count] = i;
Count++;
}
}
int[] OutFactors = new int[Count];
for (int i = 0; i < OutFactorsLength; i++) {
OutFactors [i] = temp [i];
}
return OutFactors;
//by NWinterSS
}
使用的时候,创建一个int[]然后让它等于这个函数就可以调出了。没有优化,数比较大的话比较耗资源,凑活用吧
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)