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();
        //}
    }
}
相关推荐
m0_748708051 分钟前
C++中的观察者模式实战
开发语言·c++·算法
qq_5375626713 分钟前
跨语言调用C++接口
开发语言·c++·算法
wjs202424 分钟前
DOM CDATA
开发语言
Tingjct25 分钟前
【初阶数据结构-二叉树】
c语言·开发语言·数据结构·算法
猷咪1 小时前
C++基础
开发语言·c++
IT·小灰灰1 小时前
30行PHP,利用硅基流动API,网页客服瞬间上线
开发语言·人工智能·aigc·php
快点好好学习吧1 小时前
phpize 依赖 php-config 获取 PHP 信息的庖丁解牛
android·开发语言·php
秦老师Q1 小时前
php入门教程(超详细,一篇就够了!!!)
开发语言·mysql·php·db
烟锁池塘柳01 小时前
解决Google Scholar “We‘re sorry... but your computer or network may be sending automated queries.”的问题
开发语言
是誰萆微了承諾1 小时前
php 对接deepseek
android·开发语言·php