zoukankan      html  css  js  c++  java
  • c#,运算符,if else 语句

    运算符
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication3
    {
    class Program
    {
    static void Main(string[] args)
    {
    //数学运算符加减乘除模
    int a = 1;
    int b = 2;
    int c = a + b;
    c = a++;//a++相当于a=a+1,++a=a先计算a前面的后加
    Console.WriteLine(c);
    Console.WriteLine(a);
    //比较运算符:> < >= <= <> == !=
    // bool bo=a==b;
    // Console.WriteLine(bo);
    //逻辑运算符 && || !,!用在小括号前面的
    bool bo;
    bo = a > b && a > 2;
    Console.WriteLine();
    //赋值运算符+=、-=、*=、/=、&=、||=、%=、
    a = a + b;//等同于a+=b

    //条件运算符(比较表达式)?(语句一):(语句二);
    //满足条件运行语句一,不满足条件运行语句二
    c=(a > b)?(a +1):(b+1);
    Console.WriteLine(c);
    string s;
    s = Console.ReadLine();
    a = a+int.parse(s.tostring());
    Console.WriteLine(s);
    Console.ReadLine();
    }
    }
    }
    /*语句:
    * 分支语句 :if,if else ,if elseif else, switch case
    * 循环语句:for,while,do while,foreach
    * 跳转语句:break,continue
    * 异常语句:try, catch ,finally
    **/
    int a = 0;
    if (a > 0)
    {
    Console.WriteLine("这是一个正数");
    if (a > 10)
    {
    Console.WriteLine("这是一个大于十的数");
    }

    }
    else
    {
    Console.WriteLine("这是一个小于0的数");
    }
    Console.ReadLine();

  • 相关阅读:
    POJ
    HDU
    POJ
    HDU
    HDU
    HDU
    POJ
    ZOJ
    ZOJ
    Kattis
  • 原文地址:https://www.cnblogs.com/liuyuwen900326/p/4157515.html
Copyright © 2011-2022 走看看