111,108
社区成员




class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入第一个数字:");
string num1 = Console.ReadLine();
Console.WriteLine("请输入第二个数字:");
string num2 = Console.ReadLine();
string temp = string.Format("{0} {1}", num1, num2);
Console.WriteLine(temp);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] input = Console.ReadLine().Split(new char[] {' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x.Trim())).ToArray();
foreach (int i in input)
Console.WriteLine(i);
}
}
}
1, 2, 3, 4, 5using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static Dictionary<string, string> MyScanf(string format, params string[] values)
{
var result = Regex.Match(Console.ReadLine(), format).Groups;
return values.Select((x, i) => new { key = x, value = result[i + 1].Value })
.ToDictionary(x => x.key, x => x.value);
}
static void Main(string[] args)
{
var input = MyScanf(@"(\d+) (\d+)", "a", "b");
Console.WriteLine("your input is a = {0}, b = {1}.", input["a"], input["b"]);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class RefType<T>
{
public T Value { get; set; }
public override string ToString()
{
return Value.ToString();
}
}
class Program
{
static void MyScanf(string format, params RefType<string>[] values)
{
var result = Regex.Match(Console.ReadLine(), format).Groups;
values.Select((x, i) => new { x = result[i + 1].Value, i }).ToList()
.ForEach(x => values[x.i].Value = x.x);
}
static void Main(string[] args)
{
RefType<string> a = new RefType<string>();
RefType<string> b = new RefType<string>();
MyScanf(@"(\d+) (\d+)", a, b);
Console.WriteLine("your input is a = {0}, b = {1}.", a, b);
}
}
}