罪恶倾城
2018-09-18 08:05
static void Main(string[] args)
{
string []name = new string[]{"景珍","林惠洋","成蓉","洪南昌","龙玉民","单江开","田武山","王三明"};
double []score =new double[]{90,65,88,70,46,81,100,68};
double avg =0;
double sum = 0; // 声明变量;
for (int i =0;i<score.Length;i++)
{
sum+=score[i];
} // 总分;
avg = sum/score.Length;
Console.Write("平均分是"+avg+",高于平均分的有:");//平均分;
//接下来是求高于平均分
for(int j = 0; j<score.Length;j++)
{
if(score[j]>avg)
{
Console.Write( name[j]+" " );
}
}
}
<?php $pop = ["景珍", "林惠洋", "成蓉", "红南昌", "龙玉民", "单开江", "川武山", "王一鸣"]; $score = [90,65,88,70,46,81,100,68]; $sum = array_sum($score); $avg = $sum/conut($score); echo "平均分是".$avg; echo "高于平均分的有"; $n = 0; for($i = 0;$i <count($score); $i++){ if($score[$i] > $avg){ $n = $i; }else{ continue; } echo $pop[$i]; }
using System;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
string[] name = new string[] {"景珍", "林惠洋", "成蓉", "红南昌", "龙玉民", "单开江", "川武山", "王一鸣" };
int[] score = new int[] { 90,65,88,70,46,81,100,68};
int avg,sum=0;
for (int i = 0; i < name.Length; i++)
{
sum += score[i];
}
avg = sum / score.Length;
Console.Write("平均分是" + avg+",");
Console.WriteLine("高于平均分的有:");
int n=0;
for (int j = 0; j < score.Length; j++)
{
if (score[j] > avg)
n = j;
else
continue;
Console.Write(name[j]+" ");
}
Console.ReadKey();
}
}
}
C#开发轻松入门
254118 学习 · 1459 问题
相似问题