关于条件运算符的应用

题目:输入一个24小时制的整数时间,判断所在时间段。

       int a,b;
       a = int.Parse(Console .ReadLine());//输入的时间
       b = 12;
       string s;
       s = a-b > 0 ?a-b+"pm" :a+"am" ;
       Console.WriteLine(s);

posted @ 2015-06-01 08:54  逆风的刃  阅读(158)  评论(0)    收藏  举报