项目空间

学习笔记N-183

基础语法

更新
内容块
5
阅读
约 2 分钟
路径
学习笔记 / C#
代码块C#
using  System;

namespace test1
{
    class Progream
    {
        static void Main()
        {
            Console.WriteLine("hello world");
            
            string[] arr1 = Console.ReadLine().Split(' ');
            int a = int.Parse(arr1[0]);
            int b = int.Parse(arr1[1]);

            string[] arr2 = Console.ReadLine().Split(' ');
            double c = double.Parse(arr2[0]);
            double d = double.Parse(arr2[1]);

            int x = 10;
            Console.WriteLine($"x的值是{x}");
            
            
        }
    }
}
代码块C#
using System;

namespace test1;

public class A
{
    static void Main(){

        /*
        int x = Convert.ToInt32(Console.ReadLine());
        int y = Convert.ToInt32(Console.ReadLine());
        */
        
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());

        int a = x + y;
        int b = x - y;
        double c = x * y;
        double d = x / (double)y;   //转换一个就行
        
        Console.WriteLine($"{x} + {y} = {a}");
        Console.WriteLine($"{x} - {y} = {b}");
        Console.WriteLine($"{x} * {y} = {c}");
        Console.WriteLine($"{x} * {y} = {d}");


    }
}
代码块C#
using System;
using System.Linq;
Console.WriteLine(Console.ReadLine().Split(' ').Select(double.Parse).Max());
代码块C#
using System;

class G
{
    static void Main()
    {
        string [] arr = Console.ReadLine().Split(' ');
        double n = double.Parse(arr[0]);
        double m = double.Parse(arr[1]);

        double a = 0.0;
        double b = 0.0;

        if (n < 0.0 || n > 20.0 || m < 0.0 || m > 20.0)
        {
            Console.WriteLine("The value you input is not within the required range.");
            return;
        }

        a = (n + m) * 2;
        b = n * m;
        
        Console.WriteLine($"the perimeter is {a:F2}");
        Console.WriteLine($"the area is {b:F2}");

    }
}