找回密碼 或 安全提問
 註冊
|註冊|登錄

伊莉討論區

搜索
感激所有對伊莉作出奉獻的人尊貴會員無限看帖不用回覆認識好友、聊天,分享生活趣事
催眠柯南overlord銀魂旬果自慰
teachingicloud下metal sl淺水俺を欲し我的王妃juq 663

休閒聊天興趣交流學術文化旅遊交流飲食交流家庭事務PC GAMETV GAME
熱門線上其他線上感情感性寵物交流家族門派動漫交流貼圖分享BL/GL
音樂世界影視娛樂女性頻道潮流資訊BT下載區GB下載區下載分享短片
電腦資訊數碼產品手機交流交易廣場網站事務長篇小說體育運動時事經濟
上班一族博彩娛樂

[簡]狼與辛香料 Merch

[簡]終末的火車前往何

(4月新番)[繁]怪人的

(4月新番)[繁]恰如細

[繁]劇場版 鬼太郎誕

✡ 神印王座・100・20
C & C++ 語言C# 語言Visual Basic 語言PHP 語言JAVA 語言
查看: 4211|回復: 2
打印上一主題下一主題

[求助]作業求助!![複製鏈接]

Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6

帖子
9
積分
1555 點
潛水值
26320 米
跳轉到指定樓層
樓主
發表於 2016-11-8 11:33 PM|只看該作者|倒序瀏覽

以下5題是小弟沒解開的題目 請求大大們的幫助指點迷津








附件: 你需要登錄才可以下載或查看附件。沒有帳號?註冊
分享分享0收藏收藏0支持支持0
若新密碼無法使用,可能是數據未更新。請使用舊密碼看看。

使用道具檢舉

Rank: 1

帖子
61
積分
49 點
潛水值
26810 米
頭香
發表於 2016-11-9 03:19 PM|只看該作者
第二題
  1. //讀檔案內容到字串陣列
  2.             //string[] arr1 = System.IO.File.ReadAllLines("input.txt");
  3.             //此處用宣告字串代替
  4.             string[] arr1 = new string[4] { "3 2", "43 21", "-28 90", "27 17" };
  5.             //切割字串並轉成數字放進陣列
  6.             int[,] arr2 = new int[4, 2];
  7.             for (int i = 0; i < 4; i++)
  8.             {
  9.                 string[] temp = arr1[i].Split(' ');
  10.                 arr2[i, 0] = Convert.ToInt32(temp[0]);
  11.                 arr2[i, 1] = Convert.ToInt32(temp[1]);
  12.             }
  13.             int maxI = 0, maxJ = 0;
  14.             int minI = 0, minJ = 0;
  15.             int max = arr2[0, 0], min = arr2[0, 0];
  16.             for (int i = 0; i <= arr2.GetUpperBound(0); i++)
  17.             {
  18.                 for (int j = 0; j <= arr2.GetUpperBound(1); j++)
  19.                 {
  20.                     if (arr2[i, j] > max)
  21.                     {
  22.                         maxI = i;
  23.                         maxJ = j;
  24.                         max = arr2[i, j];
  25.                     }
  26.                     else if (arr2[i, j] < min)
  27.                     {
  28.                         min = arr2[i, j];
  29.                         minI = i;
  30.                         minJ = j;
  31.                     }
  32.                 }
  33.             }
  34.             Console.WriteLine("max:{0}({1},{2})",max,maxI,maxJ);
  35.             Console.WriteLine("min:{0}({1},{2})",min,minI,minJ);
複製代碼
第三題
  1. Console.Write("請輸入一個正整數:");
  2.             int  money = Convert.ToInt32(Console.ReadLine());
  3.             int count50 = 0;
  4.             int count10 = 0;
  5.             int count5 = 0;
  6.             int count1 = 0;
  7.             count50 = money / 50;
  8.             count10 = (money - (count50 * 50)) / 10;
  9.             count5 = (money - count50 * 50 - count10 * 10) / 5;
  10.             count1 = money - count50 * 50 - count10 * 10 - count5 * 5;
  11.             Console.WriteLine("{0} {1} {2} {3}", count50, count10, count5, count1);
複製代碼
第五題
先建一個方法
  1. static double GetVolume(double l,double w, double h)
  2. {
  3.             return w * h * l;
  4. }
複製代碼
呼叫方法
  1. Console.Write("請輸入三個浮點數(以分號分隔):");
  2.             string[] input = Console.ReadLine().Split(';');
  3.             double temp;
  4.             double[] inputD = input.Select(str => double.TryParse(str, out temp) ? temp : 0).ToArray();
  5.             Console.WriteLine("長方體的長為" + inputD[0].ToString("0.000"));
  6.             Console.WriteLine("長方體的寬為" + inputD[1].ToString("0.000"));
  7.             Console.WriteLine("長方體的高為" + inputD[2].ToString("0.000"));
  8.             Console.WriteLine("長方體的體積為" + GetVolume(inputD[0], inputD[1], inputD[2]).ToString("0.00"));
複製代碼
第八題
  1. string input = "aeiou";
  2.             Hashtable ht = new Hashtable();
  3.             for (int i = 0; i < input.Length; i++)
  4.             {
  5.                 if (ht.ContainsKey(input[i]))//已存在個數加1
  6.                     ht[input[i]] = Convert.ToInt32(ht[input[i]]) + 1;
  7.                 else
  8.                     ht.Add(input[i], 1);//增加新的key
  9.             }
  10.             foreach (char s in ht.Keys)
  11.             {
  12.                 Console.WriteLine("{0}:{1}", s, ht[s]);
  13.             }
複製代碼
第九題
  1. //從檔案讀入資料
  2.             //string[] Alines = System.IO.File.ReadAllLines("inputA.txt");
  3.             //string[] Blines = System.IO.File.ReadAllLines("inputB.txt");
  4.             //切割字串並轉成數字放進陣列
  5.             //以下假設已將檔案內矩陣都轉進陣列(此處用宣告代替)
  6.             int[,] A = new int[3, 3] { { 1, 4, 7 }, { 2, 5, 8 }, { 3, 6, 9 } };
  7.             int[,] B = new int[3, 3] { { 1, 4, 7 }, { 2, 5, 8 }, { 3, 6, 9 } };
  8.             int[,] C = new int[3, 3];//存相加結果
  9.             int[,] D = new int[3, 3];//存相減結果
  10.             int[,] E = new int[3, 3];//存相乘結果
  11.             
  12.             for (int row = 0; row  <= E.GetUpperBound(0); row++)
  13.             {
  14.                 for (int col = 0; col <= E.GetUpperBound(1); col++)
  15.                 {
  16.                     C[row, col] = A[row, col] + B[row, col];//相加
  17.                     D[row, col] = A[row, col] - B[row, col];//相減
  18.                     //相乘
  19.                     for (int inner = 0; inner <= B.GetUpperBound(0); inner++)
  20.                     {
  21.                         E[row, col] += A[row, inner] * B[inner, col];
  22.                     }
  23.                 }
  24.             }
  25.             //相加結果
  26.             for (int i = 0; i <= C.GetUpperBound(0); i++)
  27.             {
  28.                 for (int j = 0; j <= C.GetUpperBound(1); j++)
  29.                 {
  30.                     Console.Write("{0} ", C[i, j]);
  31.                 }
  32.                 Console.WriteLine();
  33.             }
  34.             //相減結果
  35.             for (int i = 0; i <= D.GetUpperBound(0); i++)
  36.             {
  37.                 for (int j = 0; j <= D.GetUpperBound(1); j++)
  38.                 {
  39.                     Console.Write("{0} ", D[i, j]);
  40.                 }
  41.                 Console.WriteLine();
  42.             }
  43.             //相乘結果
  44.             for (int i = 0; i <= E.GetUpperBound(0); i++)
  45.             {
  46.                 for (int j = 0; j <= E.GetUpperBound(1); j++)
  47.                 {
  48.                     Console.Write("{0} ", E[i, j]);
  49.                 }
  50.                 Console.WriteLine();
  51.             }
複製代碼
...
瀏覽完整內容,請先 註冊登入會員

點評

chenyy1023 太感謝您了!! 另外問一下 讀入檔案是需要另外建立一個txt檔的意思嗎?  發表於 2016-11-10 12:25 AM

使用道具檢舉

Rank: 1

帖子
61
積分
49 點
潛水值
26810 米
3
發表於 2016-11-10 08:43 AM|只看該作者
若有安裝色情守門員,可用無界、自由門等軟件瀏覽伊莉。或使用以下網址瀏覽伊莉: http://www.eyny.com:81/index.php
讀入檔案是需要另外建立一個txt檔的意思嗎? 是的
您的第二題需要一個input.txt,第九題最好分成二個txt

使用道具檢舉

您需要登錄後才可以回帖 登錄 | 註冊

Powered by Discuz!

© Comsenz Inc.

重要聲明:本討論區是以即時上載留言的方式運作,對所有留言的真實性、完整性及立場等,不負任何法律責任。而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。於有關情形下,用戶應尋求專業意見(如涉及醫療、法律或投資等問題)。 由於本討論區受到「即時上載留言」運作方式所規限,故不能完全監察所有留言,若讀者發現有留言出現問題,請聯絡我們。有權刪除任何留言及拒絕任何人士上載留言,同時亦有不刪除留言的權利。切勿上傳和撰寫 侵犯版權(未經授權)、粗言穢語、誹謗、渲染色情暴力或人身攻擊的言論,敬請自律。本網站保留一切法律權利。
回頂部