C# 1124 接收



csharp 复制代码
namespace Test
{
    internal class Program
    {
        public double AverageList(int[] input)
        {
            
            double sum = 0;
            for (int i = 0; i<input.Length; i++) { 
            sum+= input[i];
            }
            return sum/10;
        }
        //string类型
        //List<int>是什么类型?数组吗? 怎么接收
            
        static void Main(string[] args)
            
        {
            //Console.ReadLine();
            //要求用户输入数字
         //   Console.WriteLine("Pl input nums;10 nums ,分割");
            //接收用户输入内容
            //字符串数组?
            //定义字符串数组
            //定义了一个数组
            int[] input = new int[10];
            for (int i = 0; i < input.Length-1; i++)
            {

                Console.WriteLine(i+"'s num is:");
                input[i] = Console.Read();
                Console.WriteLine(i+"'s num is",input[i]);
            }
            Program program = new Program();
            double res=program.AverageList(input);
            Console.WriteLine("res:"+res);
            //string input = "";
           // Console.WriteLine("pl input 10 nums,and , like:1,2,3");
          // AverageList( input);
        
           
           //Console.ReadLine();
            //判断用户输入内容 是否为数字?
            //以,为分割打印
            //如何分割string
          //  string[] strItems = input.Split(',');

            //字符串转换 type.Parse(string)
            //字符串数组
            //int sum = 0;
            //for (int i = 0; i < strItems.Length; i++)
            //{
            //    int j=int.Parse(strItems[i]);
            //    sum+=j;
            //}

          //  Console.WriteLine("Hello, World!");
        }

        //private static void AverageList(int[] input)
        //{
        //    throw new NotImplementedException();
        //}

        //private static void AverageList(string input)
        //{
        //    throw new NotImplementedException();
        //}
    }
}






csharp 复制代码
namespace Test
{
    internal class Program
    {
        public double AverageList(int[] input)
        {
            
            double sum = 0;
            for (int i = 0; i<input.Length; i++) { 
            sum+= input[i];
            }
            Console.WriteLine("sum is:"+sum);
            return sum/10;
        }
        //string类型
        //List<int>是什么类型?数组吗? 怎么接收
            
        static void Main(string[] args)
            
        {
            //Console.ReadLine();
            //要求用户输入数字
         //   Console.WriteLine("Pl input nums;10 nums ,分割");
            //接收用户输入内容
            //字符串数组?
            //定义字符串数组
            //定义了一个数组
            int[] input = new int[10];
            for (int i = 0; i < input.Length-1; i++)
            {

                Console.WriteLine(i+"'s num is:");
                input[i] = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(i+"'s num is"+input[i]);
            }
            Program program = new Program();
            double res=program.AverageList(input);
            Console.WriteLine("res:"+res);
            //string input = "";
           // Console.WriteLine("pl input 10 nums,and , like:1,2,3");
          // AverageList( input);
        
           
           //Console.ReadLine();
            //判断用户输入内容 是否为数字?
            //以,为分割打印
            //如何分割string
          //  string[] strItems = input.Split(',');

            //字符串转换 type.Parse(string)
            //字符串数组
            //int sum = 0;
            //for (int i = 0; i < strItems.Length; i++)
            //{
            //    int j=int.Parse(strItems[i]);
            //    sum+=j;
            //}

          //  Console.WriteLine("Hello, World!");
        }

        //private static void AverageList(int[] input)
        //{
        //    throw new NotImplementedException();
        //}

        //private static void AverageList(string input)
        //{
        //    throw new NotImplementedException();
        //}
    }
}
相关推荐
Wang's Blog4 小时前
Go-Zero 项目开发43:基于 Filebeat 收集各个服务的日志信息
开发语言·golang·go-zero·filebeat
丈剑走天涯5 小时前
JDK 17 正式特性
java·开发语言
秋田君5 小时前
QT_QFontDialog类字体对话框
开发语言·qt
圣光SG5 小时前
Java操作题练习(七)
java·开发语言·算法
麻瓜老宋6 小时前
AI开发C语言应用按步走,表达式计算器calc的第二十三步,多行输入、进制输出、错误恢复、常量折叠、配置加载等
c语言·开发语言·atomcode
q567315237 小时前
企业级 HTTP 代理采购选型:技术评估清单 15 项
开发语言·网络·爬虫·网络协议·http·隧道ip·代理ip
天天进步20157 小时前
Python全栈项目--智能办公自动化系统
开发语言·python
czhc11400756637 小时前
7.29:树形;
c#
cm04Z9c918 小时前
C#摸鱼实录——IoC与DI案例详解
开发语言·c#
long3168 小时前
Java 新手入门与实战开发指南
java·开发语言