snrg.net
当前位置:首页 >> 设计一个C#控制台应用程序项目,读入一组整数(以... >>

设计一个C#控制台应用程序项目,读入一组整数(以...

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...

using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string strtemp = Console.ReadLine(); Console.WriteLine("奇数和:{0}",jisuanjis...

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...

static void Main(string[] args) { int num =0; List mylist = new List(); string f = Console.ReadLine(); while (f != "0") { if (int.TryParse(f, out num)) { mylist.Add(num); } else { Console.WriteLine("输入无效"); } f = Console.Re...

static void Main(string[] args) { int intInput = 0; while (true) { Console.Write("请输入一个大于0的正整数:"); string strInput = Console.ReadLine(); if (int.TryParse(strInput, out intInput) && intInput > 0) break; } int result ...

class Program { // 声明委托 public delegate Double SquareCallback(Double x, Double y); public static Double GetSumResult(Double x, Double y) { return Math.Pow(x, 2)+Math.Pow(y,2); } public static Double GetSubtractionResult(Dou...

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...

string aa=Console.ReadLine(); char[] bb=aa.ToCharArry(); for(int i=bb.length-1;i>=0;i--) { Console.Write(bb[i]); } 纯手写,不知道有错没,没编译没调试

示例代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 class Program { static void Main(string[] args) { while (true) { Test(); } Console.ReadKey(true); } static void Test() { ConsoleKeyInfo keyinfo = Console...

见下面代码 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("请输入十个数"); ...

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