C#初学感知(1)

1、c#与java高度类似

2、学习网站:

迈出使用 C# 的第一步 - Learn | Microsoft Docs​​​​​

C# 教程 | 菜鸟教程 (runoob.com)

3、工具visual studio

4、代码训练一:

using System;
using System.Collections.Generic;

public class Program
{
    static void Main(String[] args)
    {
        Random random = new Random();
        int num1 = random.Next(1, 7);
        int num2 = random.Next(1, 7);
        int num3=random.Next(1, 7);
        int total=num1 + num2+num3;
        Console.WriteLine($"{num1}+{num2}+{num3}={total}");

        if (num1 == num2 || num2 == num3 || num3 == num1) { Console.WriteLine("恭喜+2"); 
        total = total+2;
        }
        if (total < 15)
        {
            Console.WriteLine("lose");
        }
        else  { Console.WriteLine("win"); }
    }
}

代码训练二:

// See C# console app template changes in .NET 6 - .NET | Microsoft Docs for more information
using System;
using System.Collections.Generic;

public class Program
{
static void Main(String[] args)
{
//Console.WriteLine("Hello, World!");
String[] shops = { "笔记本电脑", "鼠标", "键盘", "USB数据线" };
int[] ku = {3, 2,2,0};
int[] bu = {2, 4,2,0};
for(int i = 0; i < shops.Length; i++)
{
Console.WriteLine($"{shops[i]}库存为:{ku[i]},补货量:{bu[i]}");
ku[i] = ku[i] + bu[i];
if (ku[i] >= 5)
{
ku[i] -= 5;
Console.WriteLine($"出库提示,{shops[i]}的剩余库存为:{ku[i]}");
}
if(ku[i] <= 1)
{
Console.WriteLine("库存不足");
}
}
}
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值