> 其他 >
C#输入一组非0整数(以0作为输入结束标志)到一维数组中,求出这一组数的平均值,统计出正数和负数的个数.
如,输入4,5,6,0,则输出 5
是C#的问题,求解
人气:345 ℃ 时间:2019-08-17 16:30:10
解答
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace baidu_shurutongji{    class Program    ...int n;int sum = 0;int[] count=new int[1000];int pos = 0;int neg=0;Console.WriteLine("请输入(以0作为输入结束标志)");n = int.Parse(Console .ReadLine ());for (int i = 0; n != 0;i++ ){count[i] = n;sum = sum + n;if (n > 0) pos++;
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版