1 条题解

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

    C :

    #include<stdio.h>
    void main(){
    	int t,k;
    	scanf("%d%d",&t,&k);
    	if(t==k){
    		printf("tie");
    	}else{
    		if(t==1 && k==2){
    			printf("win");
    		}else if(t==1 && k==3){
    			printf("lose");
    		}else if(t==2 && k==1){
    			printf("lose");
    		}else if(t==2 && k==3){
    			printf("win");
    		}else if(t==3 && k==1){
    			printf("win");
    		}else if(t==3 && k==2){
    			printf("lose");
    		}
    	}
    }
    

    C++ :

    #include<iostream>
    using namespace std;
    int main(){
    	int a,b;
    	cin>>a>>b;
    	if(a==1&&b==2 ||a==2&&b==3 ||a==3&&b==1){
    		cout<<"win"<<endl;
    	}else{
    		if(a==b){
    			cout<<"tie"<<endl;
    		}else{
    			cout<<"lose"<<endl;
    		}
    	
    	}
    	
    }
    

    Pascal :

    var a,b:longint;
    begin
      read(a,b);
      if a=1 then
       begin
        if b=2 then writeln('win');
        if b=3 then writeln('lose');
        if b=1 then writeln('tie');
       end;
      if a=2 then
       begin
        if b=3 then writeln('win');
        if b=1 then writeln('lose');
        if b=2 then writeln('tie');
       end;
      if a=3 then
       begin
        if b=1 then writeln('win');
            if b=2 then writeln('lose');
        if b=3 then writeln('tie');
       end;
    end.
    

    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[] strArray=str.split(" ");
    		String a=strArray[0];
    		String b=strArray[1];
    		if(a.equals(b)){
    			System.out.println("tie");
    		}else{
    			if(Integer.valueOf(a)-Integer.valueOf(b)==-1||Integer.valueOf(a)-Integer.valueOf(b)==2){
    				System.out.println("win");
    			}else{
    				System.out.println("lose");
    			}
    		}
    	}
    }
    

    Python :

    a,b = map(int,input().split());
    
    if b - a != 2:
        if a < b:
            print('win')
        elif a == b:
            print('tie')
        elif a - b == 2:
            print('win')
        else :
            print('lose')
    else:
        print('lose')
    
    
    
    
    • 1

    信息

    ID
    47
    时间
    1000ms
    内存
    512MiB
    难度
    10
    标签
    递交数
    3
    已通过
    2
    上传者