C#基础练习。教科书习题1

1. int a=1234,b=-1234;
输出:
a=1234,b=-1234
a=01234,b=-01234
a=¥1,234,000 , b=¥-1,234,000

	int a = 1234, b = -1234;
	Console.WriteLine("a={0},b={1}", a, b);
	Console.WriteLine("a={0:D5},b={1:D5}", a, b);
	Console.WriteLine("a={0:c3},b={1:c2}",a,b);

2.double d=123.456;
输出:
¥123.46
1.2346E+002
123.4560
123.456
123.46

	double d = 123.456;
	Console.WriteLine("{0,5:c}", d);
	Console.WriteLine("{0:E4}", d);
	Console.WriteLine("{0:f4}", d);
	Console.WriteLine("{0:g}", d);
	Console.WriteLine("{0:n}", d);

3.声明一个学生结构类型Stud,包含学号、姓名和出生日期成员;定义Stud结构的两个学生s1,s2并赋值,求他们出生在星期几以及他们的出生相差的天数

	enum WeekDay {
   星期日,星期一,星期二,星期三,星期四,星期五,星期六};
    class Program
    {
   
        public struct Stud
        {
   
            public int num;
            public string name;
            public DateTime brithday;

        }
        static void Main(string[] args)
        {
   
        //思路1
        	Stud s1 = new Stud();
            Stud s2 = new Stud();
            s1.name = "李明";
            s1.num = 1;
            s1.brithday = new DateTime(1985, 10, 18)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值