voidmain(){//算数运算符int a =8;int b =7;print(a+b);//加print(a-b);//减print(a*b);//乘print(a/b);//除print(a%b);//除、取余print(a~/b);//除、取整}
//关系运算符voidmain(){int a =8;int b =7;print(a==b);print(a!=b);print(a>b);print(a<b);print(a>=b);print(a<=b);}
//逻辑运算符voidmain(){//取反
bool flag =true;print(!flag);//并且&&,全为true(真)时,值为true
bool a =true;
bool b =false;print(a && b);//或者||,任意一个值为true时,值为trueprint(a || b);}
//赋值运算符voidmain(){//基础赋值运算符 =int a =1;// b??=20;当b的值为空时,将b赋值为23;int b;
b??=20;//复合赋值,其他同理int c =8;
c +=7;//同c = c + 7;
c -=7;//同c = c - 7;
c *=7;//同c = c * 7;}
//条件表达式voidmain(){//if else
bool flag =true;if(flag){}elseif(!flag){}else{}//switch case;如果不加break,会继续向下运行。int a =1;switch(a){case0:print("zhe");break;case1:print("she");break;case2:print("che");break;default:break;}//三目运算符;当flag为true时,a=1;否则a=0;int a = flag?1:0;//??前值为空时,表达式等于后值。前值不为空,则表达式等于前值var a;var b = a ??10;}