回覆列表
  • 1 # dynus553

    usingSystem;publicclassTest{publicstaticvoidMain(string[]args){intc1=0,c2=0;doubled,sum1=0,sum2=0;Console.WriteLine("請輸入若干個數,每行一個,輸入0結束。");while(true){d=Convert.ToDouble(Console.ReadLine());if(d>0){c1++;sum1+=d;}elseif(d<0){c2++;sum2+=d;}else{break;}}Console.WriteLine("正數的平均值是:{0}",sum1/c1);Console.WriteLine("負數的平均值是:{0}",sum2/c2);Console.Write("Pressanykeytocontinue...");Console.ReadLine();}}

  • 2 # 使用者1593105253696

    using System;

    public class Test

    {

    public static void Main(string[] args)

    {

    int c1=0,c2=0;

    double d,sum1=0,sum2=0;

    Console.WriteLine("請輸入若干個數,每行一個,輸入0結束。");

    while(true)

    {

    d=Convert.ToDouble(Console.ReadLine());

    if(d>0)

    {

    c1++;

    sum1+=d;

    }

    else if(d

    {

    c2++;

    sum2+=d;

    }

    else

    {

    break;

    }

    }

    Console.WriteLine("正數的平均值是:{0}",sum1/c1);

    Console.WriteLine("負數的平均值是:{0}",sum2/c2);

    Console.Write("Press any key to continue . . . ");

    Console.ReadLine();

    }

    }

  • 中秋節和大豐收的關聯?
  • 藍天白雲是表示顏色的成語嗎?