Visual Studio-图形用户界面设计-9.14第二讲

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();
            }
            
        }
    }
}

  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值