- #include <stdio.h>
- int main(int argc, const char * argv[]) {
- int score;
- printf("请输入一个60到100的整数:\n");
-
- scanf("%d",&score);
-
- char shuchu;
-
- if (score>60&&score<100) {
- shuchu = (score>60&&score<80)?'c':((score>=80&&score<90)?'b':'a');
- }else{
-
- printf("输入不合法");
- return 0;
- }
- printf("shuchu = %c\n",shuchu);
-
- return 0;
- }
复制代码 像这样写就行了,按照要求使用了三目运算符 |