·小李有20个苹果,小王有10根香蕉,他们想和对方进行交换,请实现:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chess
{
class Program
{
static void Main(string[] args)
{
string xiaoLi = "20个苹果";
string xiaoWang = "10根香蕉";
string t = xiaoLi;
xiaoLi = xiaoWang;
xiaoWang= t;
Console.WriteLine("小李有:"+xiaoLi);
Console.WriteLine("小王有:" + xiaoWang);
}
}
}
·计算任意三门成绩的总分,平均分(Csharp Unity Math)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chess
{
class Program
{
static void Main(string[] args)
{
float Csharp = 99, Unity = 100, Math = 60;
float sum = Csharp + Unity + Math;
float avg = sum / 3;
Console.WriteLine("总分为:" + sum);
Console.WriteLine("平均分为:" + avg);
}
}
}
·计算一个半径为5的圆的面积和周长
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chess
{
class Program
{
static void Main(string[] args)
{
const float PI = 3.14159f;
int r = 5;
float C = 2 * PI * r;
float S = PI * r * r;
Console.WriteLine("周长为:" + C);
Console.WriteLine("半径为:" + S);
}
}
}
·某商店T-shirt价格为285元/件,裤子的价格为720元/条,小李在该店买了2件T-shirt和3条裤子,请计算小李应该付多少钱?打3.8折之后呢?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chess
{
class Program
{
static void Main(string[] args)
{
float cloth = 285;
float trousers = 720;
float total = 2 * cloth + 3 * trousers;
float cheaper = total * 0.38f;
Console.WriteLine("本次消费的总价为:" + total+"元");
Console.WriteLine("打折后的价格为:" + cheaper + "元");
}
}
}
该系列专栏为网课课程笔记,仅用于学习参考。