using System;
namespace Lesson01_1
{
class MainClass
{
public static void Main (string[] args){
//Main 函数 -> 编译 -> 运行
//注释的内容不会进行编译,也不会被执行
//---单行注释
/*
* ---多行注释
*/
// Console.WriteLine ("Hello World!");
//2.基本数据类型
/*
* bool,byte,sbyte,short,ushort,int,float,char,double,decimal
*/
//一个字节等于8个二进制位
//3.1 常量
//3.2 变量
//定义一个变量
/*
* int:变量类型修饰符
* age:变量名
* 18:age变量的初始值
*/
// int age = 18;
// char b = '0';
// short d = 30;
// float c;
// double e = 2.1234;
//3.3 运算符
// int a = 10;
// int b = 20;
// a = a + b; a = 30
// a = a / b; a = 0
// a = a % b;求余 a = 10
/*
* ++ , --
* 如果++在前线进行加一运算
* 如果++在后线进行运算再加一
*/
// int c = a++;
// b = ++c;
// c = 10 b = 11
//3.4.1 控制台输出函数
// Console.WriteLine("df");//控制台输出一行内容(换行)
// Console.Write("sdsdsd");//控制台输出一行内容(不换行)
// Console.WriteLine("*****");
// Console.WriteLine (" *** ");
// Console.WriteLine (" * ");
//3.4.2 输入函数
/*
Console.Read(); --获取字符的ascii码
Console.ReadLine ();--获取一行字符串(用户输入回车结束)
Console.ReadKey ();--获取字符,字符存在KeyChar属性中
*/
//如何将字符串(字符转换成其他数据类型)
// Console.WriteLine("请输入两个数");
// string a = Console.ReadLine ();
// string b = Console.ReadLine ();
// float num1 = Convert.ToSingle (a);
// float num2 = float.Parse (b);
// Console.WriteLine ("请输入两个数字,中间用回车分隔");
// double a = Convert.ToDouble (Console.ReadLine ());
// double b = Convert.ToDouble (Console.ReadLine ());
// Console.WriteLine ("它们的和是{0}", a + b);
// Console.WriteLine ("它们的差是{0}", a - b);
// Console.WriteLine ("它们的积是{0}", a * b);
// Console.WriteLine ("它们的商是{0:F}", a / b);
//4 数据类型转换
/*
* 1.隐式转换
* 从小到大
* 2.显示转换(强制类型转换)
* 从大到小,会损失精度
*/
// float a = 18 / 4;
// Console.WriteLine (a);
// string s = "sfafdff";
// string i = "当时的不仅是是";
// Console.WriteLine (s.Length);
// Console.WriteLine (i.Length);
//作业
//1.
// Console.WriteLine(" *");
// Console.WriteLine(" *** ");
// Console.WriteLine("***** ");
//2.
// Console.Write("Enter an amout:");
// float i = float.Parse (Console.ReadLine ());
// Console.WriteLine("With tax:${0:F}",i+i*0.05);
//3.
// float a = float.Parse(Console.ReadLine());
// float b = float.Parse(Console.ReadLine());
// float c = a / b * 100f;
// Console.WriteLine ("{0:F}%", c);
//4.
// float num1 = float.Parse(Console.ReadLine());
// float num2 = float.Parse (Console.ReadLine ());
// Console.WriteLine ("{0} + {1} = {2}", num1, num2, num1 + num2);
// Console.WriteLine ("{0} - {1} = {2}", num1, num2, num1 - num2);
// Console.WriteLine ("{0} * {1} = {2}", num1, num2, num1 * num2);
// Console.WriteLine ("{0} / {1} = {2}", num1, num2, num1 / num2);
//5.
// int i = 1;
// ++i;
// Console.WriteLine ("i = {0}", i++);
// int j = 1;
// j++;
// Console.WriteLine ("j = {0}", ++j);
//B
//1
// Console.Write("Enter a dollar amout:");
// int money = int.Parse (Console.ReadLine ());
// Console.WriteLine ("$20 bills:{0}", money / 20);
// Console.WriteLine ("$10 bills:{0}", money % 20 /10);
// Console.WriteLine ("$5 bills:{0}", money % 20 % 10 / 5 );
// Console.WriteLine ("$1 bills:{0}", money % 20 % 10 % 5 );
//2
// Console.Write("请输入一个字符:");
// int a = Console.Read ();
// Console.WriteLine ("它的ASCII的值是:{0}", a);
//3
// float i = 100;
// string s = "100";
// Console.WriteLine (i.GetType ().ToString ());
// Console.WriteLine (s.GetType ().ToString ());
}
}
}