
using System;
namespace _010_编程题
{
class Program
{
static void Main(string[] args)
{
//// 123
//// 123/100
//int number = Convert.ToInt32(Console.ReadLine());
//int ge = number % 10;
//int shi = (number / 10) % 10;
//int bai = number / 100;
//Console.WriteLine("" + ge + shi + bai);
//// 23452
//int number = Convert.ToInt32(Console.ReadLine());
//int shi = (number / 10) % 10;
//int qian = (number / 1000) % 10;
//int numberNew = qian * 10 + shi;
//char c = (char)numberNew;
//Console.WriteLine(c);
//int a = 3;
//int b = a++ + a++;
//// 3 + a++ //a=4
//// 3 + 4 //a=5
//Console.WriteLine(b);
//Console.WriteLine(a);
//int a = 3;
//int b = a++ + (++a);
//// 3 + (++a) //a=4
//// 3 + 5 //a=5
//Console.WriteLine(b);
//Console.WriteLine(a);
int mathScore=Convert.ToInt32(Console.ReadLine());
int englishScore=Convert.ToInt32(Console.ReadLine());
bool isGetAward = mathScore >= 90 && englishScore >= 90;
Console.WriteLine(isGetAward);
}
}
}
using System;
namespace _011_运算符的优先级
{
class Program
{
static void Main(string[] args)
{
int res = (3 + 2) * 4;
Console.WriteLine(res);//20
}
}
}
using System;
namespace _010_逻辑运算符
{
class Program
{
static void Main(string[] args)
{
// &&和 ||或 !非
//bool a = (3 < 4) && (9 < 10);// true && true
bool a = true && true;
bool b = (3 < 2) || (9 < 7);
//bool c = !(4 < 7);
bool c = !true;//取反
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(c);
}
}
}
using System;
namespace _009_关系运算符和布尔类型
{
class Program
{
static void Main(string[] args)
{
// bool a = true;//是的 真的 满足条件 1
// bool b = false;//不是 假的 不满足条件 0
// Console.WriteLine(a);//Ctrl+D 快速复制一行代码
// Console.WriteLine(b);
bool a = 45 == 67;
bool b = 45 < 67;
bool c = 45 <= 67;
bool d = 45 > 67;
bool e = 45 >= 67;
bool f = 45 != 67;
Console.WriteLine(a);//False
Console.WriteLine(b);//True
Console.WriteLine(c);//True
Console.WriteLine(d);//False
Console.WriteLine(e);//False
Console.WriteLine(f);//True
}
}
}
using System;
namespace _008_自增自减运算符
{
class Program
{
static void Main(string[] args)
{
int a = 5;
//a++;//a=a+1;
//++a;//
//int b = a++;//a++先赋值再自增 ++a先自增再赋值
//int b = ++a;
//Console.WriteLine(a + ":" + b);
Console.WriteLine(a++);
Console.WriteLine(a);
}
}
}
using System;
namespace _007_数学运算符
{
class Program
{
static void Main(string[] args)
{
//int num = 39;
//int ge = num % 10;
//int shi = num / 10;
//Console.WriteLine("个位是{0},十位数是{1}", ge, shi);
//int a = 0;
//a + 1;
//Console.WriteLine(a);
//int a = 0;
//a = a + 1;
//Console.WriteLine(a);//1
int a = 0;
a += 10;//a=a+10;
Console.WriteLine(a);
a -= 5;//5;
Console.WriteLine(a);
a *= 3;//15
Console.WriteLine(a);
a /= 6;//2
Console.WriteLine(a);
a %= 2;//0
Console.WriteLine(a);
}
}
}
c# 代码会被编译成 exe 和 dll 程序集,而不是直接就被编译成二进制文件。当程序集运行的时候 会被及时的编译成二进制文件 供电脑执行。
为什么需要这多一步呢?
老师说程序集是跑在 .net框架环境里面。多这一步是为了方便开发者能够使用到 net框架自带的一些东东。。。
using System;
namespace _007_数学运算符
{
class Program
{
static void Main(string[] args)
{
int a = 23 + 23;
int b = 2 - 10;
int c = 4 * 23;
int d = 45 / 10;
int e = 45 % 10;
double f = 45 / 10.0;
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(c);
Console.WriteLine(d);
Console.WriteLine(e);
Console.WriteLine(f);
}
}
}
using System;
namespace _006_变量研究
{
class Program
{
static void Main(string[] args)
{
int a = 23, b = 45;
// 23+45=68
//Console.WriteLine(a + "+" + b + "=" + (a + b));
Console.WriteLine("{0}+{1}={2}", a, b, a + b);//0 1 2
Console.WriteLine("两个数字相加{0}+{0}={2}",34,123,4);
//Console.WriteLine("两个数字相加{0}+{0}={3}",34,123,4);//不存在{3}报错
}
}
}
using System;
namespace _006_变量研究
{
class Program
{
static void Main(string[] args)
{
//int class namespace string void
int age;
int myAge;
int xiaomingAge;
double enemyHp;
double PI;
int HP;
int MP;
}
}
}
变量驼峰命名;
方法和类名Pascal命名。
using System;
namespace _006_变量研究
{
class Program
{
static void Main(string[] args)
{
int a = 5, b = 10;
//a = b;
//b = a;
//int temp = a;
//a = b;
//b = temp;
a = a + b;
b = a - b;
a = a - b;
Console.WriteLine(a);
Console.WriteLine(b);
}
}
}
减法交换变量:
a = a - b;//5-10=-5
b = b + a;//10+(-5)=5
a = b - a;//5-(-5)=10
using System;
namespace _005_练习题
{
class Program
{
static void Main(string[] args)
{
//int a = Convert.ToInt32(Console.ReadLine());
//int b = Convert.ToInt32(Console.ReadLine());
//int c = a + b;
//Console.WriteLine(c);
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
int c = (a + b) / 2;
Console.WriteLine(c);
}
}
}
using System;
namespace _004_字符类型
{
class Program
{
static void Main(string[] args)
{
//怎么读取数据 输入数据
//string str = Console.ReadLine(); // "12" 12
//Console.WriteLine(str + "-");
//1、类型一致 2、右边的值所需要的容器大小 小于等于左边的容器
//int a = Console.ReadLine();
string str = Console.ReadLine();// "12" 12
int strInt = Convert.ToInt32(str);// "12" 12 "df"
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(strInt + "-" + a);
}
}
}
using System;
namespace _004_字符类型
{
class Program
{
static void Main(string[] args)
{
//char a = 'c';
//int b = a;
//Console.WriteLine(a);
//Console.WriteLine(b);//99
//97 a
//int a = 97;
//char b = (char)a;//强制类型转换 强塞
//Console.WriteLine(a);
//Console.WriteLine(b);
//char a = '1';
//int b = a;
//Console.WriteLine(a);
//Console.WriteLine(b);
//char a = '\n';
//char b = '\\';
//char c = '\"';
//char d = '\t';
//char e = '\'';
//Console.WriteLine("c:\\a\\b\\c");
//Console.WriteLine(@"c:\a\b\c");
//Console.WriteLine(@"c:\\a\\b\\c");
//string str = @"www.sikiedu.com\nsiki";
// string str = @"www.sikiedu.com ""
//abc
//123
//456789";
// Console.WriteLine(str);
string str = "123" + "456";
string str2 = str + "www";
Console.WriteLine("www" + 123);
}
}
}
using System;
namespace _004_字符类型
{
class Program
{
static void Main(string[] args)
{
//char a = 'c';
//int b = a;
//Console.WriteLine(a);
//Console.WriteLine(b);//99
//97 a
int a = 97;
char b = (char)a;//强制类型转换 强塞
Console.WriteLine(a);
Console.WriteLine(b);
}
}
}
using System;
namespace _003_变量
{
class Program
{
static void Main(string[] args)
{
int a = 3, b = 8;
Console.WriteLine(a + b);//11
Console.WriteLine("a + b");//a + b
Console.WriteLine(a + "+" + b);//3+8
Console.WriteLine("a+b" + a + b);//a+b38
Console.WriteLine("a+b" + (a + b));//a+b11
}
}
}
using System;
namespace _003_变量
{
class Program
{
static void Main(string[] args)
{
int total;
//赋值
total = 4;
//int a;
//a = 1;
//int b = 1;
int a = 1;
a = 3 + 7 - 2;
int b = 3;
b = b + 1;
Console.WriteLine(a);
Console.WriteLine(b);
int c;
c = 10;//初始化
c = 11;
Console.WriteLine(c);
//female male
char sex = 'f';
sex = 'm';
}
}
}
using System;
namespace _003_变量
{
class Program
{
static void Main(string[] args)
{
//创建变量
//创建了一个数据的容器,容器的名字叫做age,容器的类型是int
//声明了一个变量,变量的名字是age
int age; //int变量类型 age变量名
//往容器里面放东西 赋值
age = 10;
double age2;
char age3;
double height;
char sex;
int count;
double ave;
int total;
double temperature;
}
}
}