1 条题解

  • 0
    @ 2026-2-10 15:41:15

    C :

    #include<stdio.h>
    int main()
    {
    	int a,b,c,d,e;
    	scanf("%d:%d",&a,&b);
    	scanf("%d:%d",&c,&d);
    		e=(c-a)*60+(d-b-1);
    	printf("%d",e);
    	return 0;		
    }
    

    C++ :

    #include <stdio.h>
    int main ( )
    {
        int a,b,c,d,n,m,x;
        scanf("%d:%d%d:%d",&a,&b,&c,&d);
        n=(c-a)*60;
        m=d-b-1;
        x=n+m;
        printf("%d",x); 
        return 0;
    } 
    

    Java :

    import java.util.Scanner;
    public class Main {
        public static void main(String [] agrs){
            Scanner input=new Scanner(System.in);
            String s1=input.nextLine();
            String[] a=s1.split(":");
            int h1=Integer.parseInt(a[0]);
            int m1=Integer.parseInt(a[1]);
            String s2=input.nextLine();
            String[] b=s2.split(":");
            int h2=Integer.parseInt(b[0]);
            int m2=Integer.parseInt(b[1]);
            System.out.println(((h2-h1)*60)+m2-m1-1);
        }
    }
    
    

    Python :

    # coding=utf-8
    #python2
    a,b = raw_input().split(':')
    a = int(a)
    b = int(b)
    x,y = raw_input().split(':')
    x = int(x)
    y = int(y)
    print((x-a)*60+y-b-1)
    

    C# :

    using System;
    using System.Collections.Generic;
    using System.Diagnostics.SymbolStore;
    using System.Linq;
    using System.Security.Cryptography;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApp2
    {
        internal class Program
        {
            static void Main()
            {
                //int[] days = { 31,28,31,30,31,30,31,31,30,31,30,31};
                string[] a1 = Console.ReadLine().Split(':');
                int m1 = Convert.ToInt32(a1[0]);
                int d1 = Convert.ToInt32(a1[1]);
                string[] b1 = Console.ReadLine().Split(':');
                int m2 = Convert.ToInt32(b1[0]);
                int d2 = Convert.ToInt32(b1[1]);
                int y = 0;
                for (int i = m1; i < m2; i++)
                {
                    y += 60;
                } 
                    y += d2 - d1 - 1;
                    Console.WriteLine(y);
                    Console.ReadKey();
    
                
    
            }
        }
    }
    
    • 1

    信息

    ID
    12
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者