using System;
namespace Hello_tomorrow { internal class Program { static void Main(string[] args) { int day = 12; int today; today = day++;//today = day++--先使用将day赋值给today,在自增;若today = ++day --先自增后使用; Console.WriteLine("day={0},today={1}", day, today);
//自减运算符
//int apples = 10;
//apples--;//等同于-apples=apples -1;
//Console.WriteLine("还剩{0}个",apples);
//自加运算符
//int myAge = 24;
//Console.WriteLine("今年我{0}岁", myAge);
//myAge++;//等同于-myAge=myAge +1;
//Console.WriteLine("明年我{0}岁", myAge);
/*已知华氏温度和摄氏温度的转换公式:
摄氏温度=(华氏温度-32)*5/9--C=(F-32)*5/9
编写一个程序输入华氏温度,输出其摄氏温度*/
//double F;
//double C;
//Console.Write("F=");
//F = Convert.ToDouble(Console.ReadLine());
//C = (F - 32) * 5 / 9;
//Console.WriteLine("C=" +C);
//int a = 9;
//Console.WriteLine(Math.Sqrt(a));
//取余运算%(取模)
//int a=9, b = 2;
//Console.WriteLine(a % b);
//double x;
//double y;
//Console.Write("x=");
//x = Convert.ToDouble (Console.ReadLine());
//y = x * x * x + 3 * x * x - 24 * x + 30;
//Console.WriteLine("y=" + y);
//int x = 10 / 3;
//double y = 10 / 3;
//double z = 10.0 / 3;
//Console.WriteLine("x={0}", x);
//Console.WriteLine("y={1}", y);
//Console.WriteLine("z={2}", z);
//北京奥运会的开幕日期是2008年8月8日,那么这天是星期几?
//y-年 m-月 d-日
//int y = 2008;
//int m = 8;
//int d = 8;
////以下是吉姆拉尔森公式。
//int week = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400 + 1) % 7;
//Console.WriteLine("2008.8.8是星期{0}", week);
//int a = 5;//a=5,b=/,t=/
//int b = 2;//a=5,b=2,t=/
//int t;//空桶法//a=5,b=2,t=/
//t = a;//a=5,b=2,t=a=5
//a = b;//a=2,b=2,t=5
//b = t;//a=2,b=5,t=5
//Console.WriteLine("a=" + a);
//Console.WriteLine("b=" + b);
//const double pi = 3.1415926;
//double r = 7;
//double area1 = pi * r * r;
//double area2 = 2 * pi * r;
//Console.WriteLine("{0}\n{1}", area1, area2);
//double pi = 3.1415926;
//Console.WriteLine("{0:#.00}", pi);
//Console.WriteLine("{0:#.000}", pi);
//Console.WriteLine("{0:#.0000}", pi);
//Console.WriteLine("{0:#.00000}", pi);
//int number = 100;
//Console.WriteLine("The number is " + number);
//Console.WriteLine("The number is {0}", number);//{0}-占位符
////格式控制符
//int i = 215;
//int j = 85;
//Console.WriteLine("{0}+{1}={2}", i, j, i + j);
//Console.WriteLine("{0,6}\n+{1,5}\n------\n{2,6}\n",i,j,i+j);
//decimal i1 = 19.23m;
//decimal j1 = 73.7m;
//Console.WriteLine("{0,8:C2}\n+{1,7:C2}\n---------\n{2,8:C2}", i1, j1, i1 + j1);//{0,8:C2}-{参数索引,数值宽度:货币格式小数位数}
//string name = "张三";
//char sex = '男';
//int age = 18;
//Console.WriteLine("姓名:{0}\n性别:{1}\n年龄:{2}", name, sex,age);
//转义字符
//Console.WriteLine("What is your name?\nMy name is Jack.");
//Console.WriteLine("c\\windows\\fonts");
//Console.WriteLine("小明说:\"我和他是朋友。\"");
////Console.WriteLine("\a好的");
//Console.WriteLine("你叫什么名字?\t我叫夏文杰。");
//Console.WriteLine(@"c\windows\fonts");
//string mySentence = "Harvard is";
//mySentence = mySentence + "ccccc";
//Console.WriteLine(mySentence);
//float pi = 3.14f;
//Console.WriteLine("圆周率是:" + pi);
////把一个字符转化为整数,从而得到字符ASCII码
//int code = (int)'A';//整数型转化字符型方法:在字符前面加(int)
//Console.WriteLine("A->{0}", code);
//char ch = (char)65;//字符型转化整数型方法:在整数前加(char)
//Console.WriteLine("65->{0}", ch);
////用十六进制形式输出。
//Console.WriteLine("\u0047\u006f\u006f\u0064\u0021");
//Console.WriteLine("\u5c0f\u56ed\u9999\u5f84\u72ec\u5f98\u5f8a");
//char tt = '玉';
//int code10 = (int)tt;
//string code16 = Convert.ToString(code10, 16);
//Console.WriteLine("{0}的Unicode编码为:{1}", tt, code16);
//数字的读取
//根据圆的半径求面积
//double r, s;
//Console.Write("r=");
//r = Convert.ToDouble(Console.ReadLine());//convert.todouble();
//s = 3.14 * r * r;
//Console.WriteLine("s=" + s);
//字符的读取
//Console.Read()用来读取一个字符。
//Console.WriteLine("请输入一个字符:");
//int ch = Console.Read();//输入一个字符,返回一个整型的ASCII编码。
//Console.WriteLine("ASCII编码为:" + ch);
//char tt = Convert.ToChar(ch);
//Console.Write(tt);
//字符串的读取
//Console.Readline()用来读取一条字符串。
//Console.WriteLine("请输入您的姓名:");
//string name = Console.ReadLine();
//Console.WriteLine("您的姓名是:" + name);
//console.writeline()-自动换行
//Console.WriteLine("山,");
//Console.WriteLine("好美的风景.");
////console.write()-不换行
//Console.Write("山,");
//Console.Write("好美的风景.");
/*字符型变量和字符串型变量的使用。*/
//string mys;
//mys = "How do you do";//这里加双引号-字符串变量
//Console.WriteLine(mys);
//mys = "I am fine";
//Console.WriteLine(mys);
//字符型变量用来存储一个字符,用关键字char声明
//char mys;
//mys = 'x';//这里是加单引号-字符变量
//Console.WriteLine(mys);
//mys = '2';
//Console.WriteLine(mys);
//mys = '#';
//Console.WriteLine(mys);
//Console.WriteLine('a');
//Console.WriteLine("a");
//Console.WriteLine('6');
//Console.WriteLine("I Love you!");
//观察程序,体验加引号和不加引号的区别
//int balance = 100000;
//Console.WriteLine("balance");//加引号的balance被看做文本,按原样输出
//Console.WriteLine(balance);//不加引号的balance被看做变量,输出的是其整型数字100000
//小明有44444.14元钱,小娟有66666.51元钱,计算他们共有多少钱。
//float balanceofming = 44444.14f;//decimal虽然是财务计算但也是可以的,只是内存占用会变多。
//float balanceofjuan = 66666.51f;
//float total = balanceofming + balanceofjuan;
//Console.WriteLine("合计:¥{0}",total);
//float x = 3.14159265358979f;
//double y = 3.14159265358979;
//Console.WriteLine("x={0}", x);
//Console.WriteLine("y={0}", y);
//short a, b;
//a = 32767;
//b = (short)(a + 1);
//Console.WriteLine("b={0}", b);//溢出
//将25489以二进制转换
//Console.WriteLine(Convert.ToString(25489, 2));
//int n;
//n = 100;
//n = 200;
//n = n + 100;
//Console.WriteLine(n);
////功能:求变量a,b的和、差、积、商。
////下面定义变量。
//int a = 7;
//int b = 2;
//int sum, dif, pro, quo;
////下面进行计算。
//sum = a + b;
//dif = a - b;
//pro = a * b;
//quo = a / b;
////下面我们输出结果。
//Console.WriteLine("{0}+{1}={2}",a,b,sum);
//Console.WriteLine("{0}-{1}={2}",a,b,dif);
//Console.WriteLine("{0}*{1}={2}",a,b,pro);
//Console.WriteLine("{0}/{1}={2}",a,b,quo);
//Console.WriteLine(Convert.ToString(89, 2));
//Console.WriteLine(Convert.ToString(89, 8));
//Console.WriteLine(Convert.ToString(8956, 16));
//Console.WriteLine(Convert.ToInt32("110011", 2));
//Console.WriteLine(Convert.ToInt32("567", 8));
//Console.WriteLine(Convert.ToInt32("6F", 16));
/*今天是我编写的第一个程序
我好高兴呀
我要记住这个日子*/
//以下是把hollowtomorrow!打印在控制台屏幕上。
//Console.WriteLine("Hello Tomorrow!");
}
}
}
标签:Convert,Console,int,double,mys,望能,学习,WriteLine,朝圣者 From: https://blog.51cto.com/u_16992697/12067312