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

一楼正解。一楼采用的逆向思维,下面是正向的,从上面的数字可以看到规律:n个1 + (n-1)个2 + 。。。+1个nstatic void Main(string[] args) { int n = 0; n = Convert.ToInt32(Console.ReadLine()); int result = sum(n); Console.WriteLine(r...

//1.只要是输入的是 0 if (Console.Read() == 48) { Environment.Exit(0); } ConsoleKeyInfo cki = Console.ReadKey(); //输入的是大键盘上的 0 if (cki.Key == ConsoleKey.D0) { Environment.Exit(0); } //输入的是小键盘上的 0 if (cki.Key =...

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

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

public int[] GetFactors(int n){ int Count = 0; int[] temp = new int[n]; for(int i = 1; i < n; i++){ if (n % i == 0) { temp [Count] = i; Count++; } } int[] OutFactors = new int[Count]; for (int i = 0; i < OutFactors.Length; i++)...

static void Main(string[] args) { int a, b,c=0; a = Convert.ToInt32(Console.ReadLine()); b = Convert.ToInt32(Console.ReadLine()); if (a >= b) c = a; else if (a < b) c = b; else Console.WriteLine("错误!"); Console.WriteLine("{0...

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

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