11.算术运算符

+,-,*,/,%

我们在使用算术运算符的时候,一定要注意算术运算符的优先级的问题.

代码示例1:
 
   
  1. namespace _12.算术运算符
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. //演示:某学生三门课的成绩为:语文:90分,数学100,英语80,请计算它的总成绩和平均成绩.
  8. int chinese = 90;
  9. int math = 100;
  10. int english = 80;
  11. Console.WriteLine("总成绩为:{0},平均成绩为:{1}.",chinese+math+english,(chinese+math+english)/3);
  12. Console.ReadKey();
  13. }
  14. }
  15. }
1047912-20161026110732125-414934080.png
 
代码示例2:
 
    
  1. namespace _13.算术运算符练习题01
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. //定义两个数分别为100和20打印两个数的和.
  8. int a = 100;
  9. int b = 20;
  10. Console.WriteLine("和为:{0}",a+b);
  11. Console.ReadKey();
  12. }
  13. }
  14. }
1047912-20161026110732515-1145063440.png
 代码示例3:
 
     
  1. namespace _13.算术运算符练习题02
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. //计算半径为5的圆的面积和周长并打印出来,(pi为3.14)
  8. const double PI = 3.14; //圆周率
  9. int r = 5; //半径为5
  10. Console.WriteLine("周长为:{0}", 2 * PI * r);
  11. Console.WriteLine("面积为:{0}",PI*r*r);
  12. Console.ReadKey();
  13. }
  14. }
  15. }
1047912-20161026110733015-2056557699.png
代码示例4:
 
    
  1. namespace _13.算术运算符的练习题03
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. //某商店T桖的价格为35元/件,裤子的价格为120元/条,小明在该店
  8. //买了3键T恤和2条裤子,请计算小明应付多少钱.
  9. int T_shirt = 35;
  10. int trousers = 120;
  11. Console.WriteLine("三件T恤和两件裤子的价格为:{0}",25*3+120*2);
  12. Console.WriteLine("以上价格打8.8折之后的价格为:{0}",(25 * 3 + 120 * 2)*88/100);
  13. Console.ReadKey();
  14. }
  15. }
  16. }

1047912-20161026110733281-837141130.png
 
 





转载于:https://www.cnblogs.com/HelloZyjS/p/5999578.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值