C#基於面向進程盤算加權均勻分的辦法。本站提示廣大學習愛好者:(C#基於面向進程盤算加權均勻分的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#基於面向進程盤算加權均勻分的辦法正文
本文實例講述了C#基於面向進程盤算加權均勻分的辦法。分享給年夜家供年夜家參考。詳細以下:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("輸出你的總共課程數:"); int score_number = 0; string score_temp = Console.ReadLine(); score_number = Convert.ToInt32(score_temp); double[] score; score = new double[score_number]; double[] unit; unit = new double[score_number]; double sum = 0; double total_credit=0; Console.WriteLine("請輸出你的各個分數:"); for (int i = 0; i <= score_number-1;i++ ) { string temp=Console.ReadLine(); score[i] = Convert.ToDouble(temp); } Console.WriteLine("請輸出你的各個權重:"); for (int i = 0; i <= score_number-1;i++ ) { string temp = Console.ReadLine(); unit[i] = Convert.ToDouble(temp); } for (int i = 0;i <= score_number-1;i++) { sum =sum+(score[i] * unit[i]); } for (int i = 0; i <= score_number-1;i++ ) { total_credit = total_credit + unit[i]; } double result = 0; result = sum / total_credit; Console.WriteLine("您的加權評均分為:"); Console.WriteLine(result); Console.ReadKey(); } } }
願望本文所述對年夜家的C#法式設計有所贊助。