码迷,mamicode.com
首页 > Windows程序 > 详细

C#学习

时间:2015-07-07 21:00:57      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HelloTomorrow
{
class Program
{
static void Main(string[] args)
{
//添加代码
//Console.WriteLine(Convert.ToString(110,2));

//下面定义变量
//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);

//下面定义变量
//float x = 3.14159265358979f;
//double y = 3.14159265358979;
//Console.WriteLine("x={0}", x);
//Console.WriteLine("y={0}", y);

//下面输出字符
//int balance = 1000000;
//Console.WriteLine("balance");
//Console.WriteLine(balance);

//下面输出字符和字符串
//Console.WriteLine(‘a‘);
//Console.WriteLine("abc");

//字符串的读取
//Console.WriteLine("Please input your name");
//String name = Console.ReadLine();
//Console.WriteLine("Your name is " + name);

//字符串的读取
//String name;
//name = Console.ReadLine();
//Console.WriteLine("Your name is {0}", name);

//字符的Unicode编码
//char character = ‘玉‘;
//int code10 = (int)character;
//string code16 = Convert.ToString(code10,16);//将16进制的变量定义为string
//Console.WriteLine("{0}的Unicode编码为:{1}",character,code16);

//转义字符
//Console.WriteLine("1.2\t1.89\t3.14\n2.75\t3.89\t239\t0.76\t6342\t3.92\a");
//Console.WriteLine("\\n\t\\t\t\\a\n\\‘\t\\‘\t\\0\a");

//画菱形
//Console.WriteLine("\t\t*\n\t*\t\t*\n*\t\t\t\t*\n\t*\t\t*\n\t\t*");//没有用控制符,用制表符\t画图,图形显得太宽太矮
// Console.WriteLine(@" *
// * *
//* *
// * *
// *");//如果没有控制符@,”“内不能出现换行符。用控制符后,”“可以出现换行符

//格式字符串
//double pi = 3.1415926;
//Console.WriteLine("{0,0:C2}\n{1,0:F4}\n{2,6:G}\n{3,8:N}\n{4,6:E}\n{5,6:e}", pi, pi, pi,pi,pi,pi);

//15-7-7 晚上
//运算符和表达式-由年月日计算星期
//int year=2008, month=8, day=8;
//int week = (day + 2*month + 3*(month + 1)/5 + year + year/4 - year/100 + year/400 + 1)%7;//基姆拉尔森公式
//Console.WriteLine("2008年8月8日是星期{0}",week);

//代数运算
//double x, y=1;
//Console.WriteLine("x = ");
//x = Convert.ToDouble(Console.ReadLine());//用户从控制台输入的数据默认为字符串类型string
//y = x * x * x + 3 * x * x - 24 * x + 30;
Console.WriteLine(Convert.ToDouble(Console.ReadLine()));

//输入华氏温度,输出摄氏温度
//double x, y;
//Console.Write("x = ");
//x = Convert.ToDouble(Console.ReadLine());
//y = (x - 32) * 5 / 9;
//Console.WriteLine("摄氏温度y = {0}",y);

//前置++和后置++的区别:前置先自加再运算,后置先运算再自加
//int x=12, y;
//y = ++x;
//Console.WriteLine("x = {0} y = {1}",x,y);

 


}
}
}

C#学习

标签:

原文地址:http://www.cnblogs.com/fun-software/p/4628488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!