c语言中的几种运算符

 

001、相等运算符

==

!=

 

002、关系运算符

>

>=

<

<=

 

003、条件运算符

a ? b:c

复制代码
[root@localhost test]# ls
test.c
[root@localhost test]# cat test.c
#include <stdio.h>

int main(void)
{
        int n1,n2;

        puts("please input two integers.");
        printf("n1 = "); scanf("%d", &n1);
        printf("n2 = "); scanf("%d", &n2);

        int max;
        max = (n1 > n2) ? n1:n2;

        printf("max is %d\n", max);

        return 0;
}
[root@localhost test]# gcc test.c -o kk
[root@localhost test]# ls
kk  test.c
[root@localhost test]# ./kk
please input two integers.
n1 = 8
n2 = 3
max is 8
[root@localhost test]# ./kk
please input two integers.
n1 = 2
n2 = 7
max is 7
复制代码

 .

 

004、逻辑非运算符

!.

 

 

 

 

 

 

 

 

.

posted @   小鲨鱼2018  阅读(9)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-09-04 什么是Phasing?
点击右上角即可分享
微信分享提示