c语言中条件运算符 + 语句
001、
[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); (n1 == n2) ? puts("equal"):puts("no equal"); //条件运算符后直接加执行语句 return 0; } [root@localhost test]# gcc test.c -o kkk [root@localhost test]# ls kkk test.c [root@localhost test]# ./kkk please input two integers. n1 = 8 n2 = 3 no equal [root@localhost test]# ./kkk please input two integers. n1 = 7 n2 = 7 equal
。