1 条题解

  • 0
    @ 2025-10-10 15:45:27

    C :

    #include<stdio.h>
    #include<string.h>
    char a[20],b[20];
    int main(){
    	scanf("%s%s",&a,&b);
    	int ah = (a[0]-'0')*10+a[1]-'0';
    	int am = (a[3]-'0')*10+a[4]-'0';
    	int as = (a[6]-'0')*10+a[7]-'0';
    	
    	int bh = (b[0]-'0')*10+b[1]-'0';
    	int bm = (b[3]-'0')*10+b[4]-'0';
    	int bs = (b[6]-'0')*10+b[7]-'0';
    	
    	int at=ah*3600+am*60+as;
    	int bt=bh*3600+bm*60+bs;
    	
    	printf("%d",at-bt);
    	return 0;
    }
    

    C++ :

    #include <iostream>
    #include <cstring>
    using namespace std;
    int main(){
    	char s[1000];
    	gets(s);
    	int h1,m1,t1;
    	 h1=(s[0]-48) * 10 + (s[1]-48) * 1;
    	 m1=(s[3]-48) * 10 + (s[4]-48) * 1;
    	 t1=(s[6]-48) * 10 + (s[7]-48) * 1;
    	 
    	 
    	 char v[1000];
    	 gets(v);
    	 int h2,m2,t2;
    	 h2=(v[0]-48) * 10 + (v[1]-48) * 1;
    	 m2=(v[3]-48) * 10 + (v[4]-48) * 1;
    	 t2=(v[6]-48) * 10 + (v[7]-48) * 1;
    	 int c;
    	 c=0;
    	 c=(h1-h2)*3600+(m1-m2)*60+(t1-t2);
    	 cout<<c<<endl;
    	 }
    

    Java :

    import java.util.Scanner;
    public class Main{
    	public static void main(String[] args) {
    		Scanner scanner=new Scanner(System.in);
    		String str=scanner.nextLine();
    		String[] timeArray=str.split(":");
    		int xh=Integer.valueOf(timeArray[0]);
    		int fz=Integer.valueOf(timeArray[1]);
    		int ms=Integer.valueOf(timeArray[2]);
    		int all=xh*3600+fz*60+ms;
    		String str1=scanner.nextLine();
    		String[] timeArray1=str1.split(":");
    		int xh1=Integer.valueOf(timeArray1[0]);
    		int fz1=Integer.valueOf(timeArray1[1]);
    		int ms1=Integer.valueOf(timeArray1[2]);
    		int all1=xh1*3600+fz1*60+ms1;
    		System.out.println(all-all1);
    	}
    }
    
    

    Python :

    a = input()
    b = input()
    x = a.split(':')
    y = b.split(':')
    c = int(x[0]) * 3600 + int(x[1]) * 60 + int(x[2]) -  int(y[0])*3600 - int(y[1])*60 - int(y[2])
    print(c)
    
    
    • 1

    信息

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