C#基于面向過程計算加權(quán)平均分的方法
更新時間:2015年07月16日 12:23:53 作者:宋勇野
這篇文章主要介紹了C#基于面向過程計算加權(quán)平均分的方法,涉及C#數(shù)學(xué)運算的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了C#基于面向過程計算加權(quán)平均分的方法。分享給大家供大家參考。具體如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("輸入你的總共課程數(shù):");
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("請輸入你的各個分?jǐn)?shù):");
for (int i = 0; i <= score_number-1;i++ )
{
string temp=Console.ReadLine();
score[i] = Convert.ToDouble(temp);
}
Console.WriteLine("請輸入你的各個權(quán)重:");
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("您的加權(quán)評均分為:");
Console.WriteLine(result);
Console.ReadKey();
}
}
}
希望本文所述對大家的C#程序設(shè)計有所幫助。
相關(guān)文章
C#并發(fā)實戰(zhàn)記錄之Parallel.ForEach使用
這篇文章主要給大家介紹了關(guān)于C#并發(fā)實戰(zhàn)記錄之Parallel.ForEach使用的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用C#具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08
C#結(jié)合JavaScript實現(xiàn)手寫板簽名效果
這篇文章主要為大家詳細(xì)介紹了C#如何結(jié)合JavaScript實現(xiàn)手寫板寫字并上傳到服務(wù)器進(jìn)行處理,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-04-04
C#如何遠(yuǎn)程讀取服務(wù)器上的文本內(nèi)容
這篇文章主要介紹了C#如何遠(yuǎn)程讀取服務(wù)器上的文本內(nèi)容,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-01-01
C#隨機(jī)設(shè)置900-1100毫秒延遲的方法
這篇文章主要介紹了C#隨機(jī)設(shè)置900-1100毫秒延遲的方法,涉及C#中Thread.Sleep方法的使用技巧,需要的朋友可以參考下2015-04-04
深入DropDownList用法的一些學(xué)習(xí)總結(jié)分析
本篇文章是對DropDownList的用法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06

