第十四节 流程控制四
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace bianli
{
class Program
{
static void Main(string[] args)
{
double y = Convert.ToDouble(Console.ReadLine());
int m = Convert.ToInt32(Console.ReadLine());
double d = Convert.ToDouble(Console.ReadLine());
double total = 365;
if(y%4==0&&y%100!=0||y%400==0)
{
total=366;
}
switch (m)
{
case 1: total -= 31; goto case 2;
case 2:
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
{
total -= 29;
}
else
total -= 28;
goto case 3;
case 3: total -= 31; goto case 4;
case 4: total -= 30; goto case 5;
case 5: total -= 31; goto case 6;
case 6: total -= 30; goto case 7;
case 7: total -= 31; goto case 8;
case 8: total -= 31; goto case 9;
case 9: total -= 30; goto case 10;
case 10: total -= 31; goto case 11;
case 11: total -= 30; goto case 12;
case 12: total -= 31; goto default;
default: total += d; break;
}
Console.WriteLine("{0}年{1}月{2}日是{3}天",y,m,d,total);
}
}
}
三木运算符?:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace sz
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("输入一个大写字母");
char ch = Convert.ToChar(Console.Read());
ch = (char.IsUpper(ch)) ?char.ToLower(ch) : ch;
Console.WriteLine(ch);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace paixu
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("我们输入三个数");
double a = Convert.ToDouble(Console.ReadLine());
double b = Convert.ToDouble(Console.ReadLine());
double c = Convert.ToDouble(Console.ReadLine());
double temp;
if (a < b)
{
temp = a;
a = b;
b = temp;
}
if (a < c)
{
temp = a;
a = c;
c = temp;
}
if (b < c)
{
temp = b;
b = c;
c = temp;
}
Console.WriteLine("{0}{1}{2}",a,b,c);
}
}
}
浙公网安备 33010602011771号