文章目录
Problem A:判断成绩是否及格
题目描述
输入成绩的分数值s,如果s≥60,则为及格,输出pass;否则为不及格,输出fail
样例输入
60
样例输出
pass
答案
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
float s = float.Parse(Console.ReadLine());
if (s >= 60)
{
Console.WriteLine("pass");
Console.ReadLine();
}
else
{
Console.WriteLine("fail");
Console.ReadLine();
}
}
}
}
Problem B:奇数与偶数
题目描述
输入整数n,如果n为奇数,输出odd;否则输出even
样例输入
1
样例输出
odd
答案
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
int s = int.Parse(Console.ReadLine());
if (s % 2 == 0)
{
Console.WriteLine("even");
Console.ReadLine();
}
else
{
Console.WriteLine("odd");
Console.ReadLine();
}
}
}
}
Problem C:闰年与平年
题目描述
输入年份y,判断这个年份是否为闰年(闰年的条件是:年份能被4整除且不能被100整除,或能被400整除)
样例输入
【测试样例1】
2000
【测试样例2】
2012
【测试样例3】
2015
【测试样例4】
1900
样例输出
【测试样例1】
leap year
【测试样例2】
leap year
【测试样例3】
non-leap year
【测试样例4】
non-leap year
答案
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
int s = int.Parse(Console.ReadLine());
if (s % 4 == 0 && s % 100 != 0 || s % 400 == 0)
{
Console.WriteLine("leap year");
Console.ReadLine();
}
else
{
Console.WriteLine("non-leap year");
Console.ReadLine();
}
}
}
}