當前位置:編程學習大全網 - 編程軟體 - 相親節目

相親節目

用什麽語言?但是我覺得想法應該是壹樣的。我用C#寫的,用隨機數生成了100個整數。我把它們從1-999放入ArrayList,然後對奇數求和。

ArrayList al = new ArrayList();

for(int I = 0;我& lt0 100;i++)

{

Random rnd = new Random(~ unchecked((int)DateTime。now . Ticks));

int rand = rnd。下壹個(1,999);

艾爾。加(蘭特);

系統。threading . thread . sleep(100);//停0.1秒生成不同的隨機數。

}

int sum = 0;

for(int I = 0;我& lt艾爾。數數;i++)

{

如果(轉換。ToInt32(al[i].ToString()) % 2 == 1)

{

總和+=轉換。ToInt32(al[i].ToString());

}

}

重要的是下面這段代碼,只生成100個隨機數,放在ArrayList裏。

  • 上一篇:VB.net 生成的應用程序運行環境是什麽
  • 下一篇:本人是大壹國貿專業準備考計算機二級
  • copyright 2024編程學習大全網