static void Main(string[] args) { //Convert轉換:不同資料型別之間的轉換; //大前提: 面兒上一定要過得去 Console.WriteLine("請輸入你的姓名:"); string strName = Console.ReadLine(); Console.WriteLine("請輸入你的數學成績:"); double douMath = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("請輸入你的語文成績:"); double douChinese = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("請輸入你的英語成績:"); double douEnglish = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("{0},你的總分是{1}, 你的平均分是{2:0.00};", strName, douMath + douChinese + douEnglish, (douMath + douChinese + douEnglish) / 3); if (douMath>=60 && douChinese>=60 && douEnglish>=60) { Console.WriteLine("恭喜你,成績合格!"); } else { Console.WriteLine("很抱歉, 你的部分成績不合格!"); } Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("46天是{0}周零{1}天;", 46 / 7, 46 % 7); Console.ReadKey(); }
static void Main(string[] args) { const int intAllSecond= 107653; int intDay = intAllSecond / (24 * 60 * 60); int intHour = (intAllSecond % (24 * 60 * 60)) / (60 * 60); int intMinute= ((intAllSecond % (24 * 60 * 60)) % (60 * 60))/60; int intSecond= intAllSecond % 60; Console.WriteLine("{0}天,{1}時,{2}分,{3}秒", intDay, intHour, intMinute, intSecond); Console.ReadKey(); }