snrg.net
当前位置:首页 >> 用C#设计一个控制台程序,要求用户输入10个数,并... >>

用C#设计一个控制台程序,要求用户输入10个数,并...

见下面代码 using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { double [] myArray = new double[10]; Console.WriteLine("请输入十个数"); ...

using System; using System.Console; class Program { public static void Main(string [] args) { int a = Integer.Parse(Console.Read()); int b = Integer.Parse(Console.Read()); Console.Write("{0}+{1}={2}\n",a,b,a+b); } } 大概这样,...

用C#编写一个控制台程序

static void Main(string[] args) { Console.WriteLine("请输入n:"); String strInput = Console.ReadLine(); int n = Convert.ToInt32(strInput); //创建用于产生随机数的Random类 Random rd = new Random(); for (int k = 0; k < n; k++) { i...

class Program{ static void Main(stringp[] args) { Console.WriteLine("输入多个值,以空格分隔"); string value = Console.ReadLine(); string[] vals = value.Split(' '); Console.WriteLine("分开展示各值"); for (int i = 0; i < vals.Len...

static void Main(string[] args) { int oddNumber = 0; int evenNumber = 0; int number = 1; while (number != 0) { number = ReadNumber(); if (number % 2 == 0) { evenNumber += number; } else { oddNumber += number; } } Console.WriteL...

Main 函数里写: Console.Write("请输入一个字符串:"); string str = Console.ReadLine(); int count = 0;foreach (char c in str){ if (char.IsLetter(c)) { count ++; }}Console.WriteLine(string.Format("字符串{0}中字母的个数为:{1}", st...

using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int z = 0; int[] number = new int[10]; for (int i = 0; i < number.Length; i++)...

static void Main(string[] args) { int n = 0; n = Convert.ToInt32(Console.ReadLine()); int result = sum(n); Console.WriteLine(result.ToString()); Console.ReadLine(); } private static int sum(int n) { int j = 1; //结果 int result...

int i=0,j=0;//先定义两个变量接受输入的值 if(int.TryParse(Console.ReadLine(),out i) { if(int.TryParse(Console.ReadLine(),out j)) { Console.WriteLine(string.Format("{0}*{1}={2}",i,j,i*j)); Console.ReadKey(); } }

网站首页 | 网站地图
All rights reserved Powered by www.snrg.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com