1.三元操作符 #includemain(){ int score; char grade; printf("input your score"); scanf("%d",&score); grade = score >= 90?'A':(score >= 60?'B':'C'); printf (...
1.三元操作符
#include<stdio.h>
main()
{
int score;
char grade;
printf("input your score");
scanf("%d",&score);
grade = score >= 90?'A':(score >= 60?'B':'C');
printf ("%dbelong is %c",score, grade);
}
三元操作符從左往右依次運算,比較運算符的優先順序大於賦值符號。
-----------------------------------------------------------------------