2 条题解

  • 0
    @ 2023-4-2 11:54:25

    《关于我做这题需要用sort这件事》

    #include<bits/stdc++.h>
    using namespace std;
    int arr[3];
    bool cmp(int a,int b){
    return a<b;
    }
    int main(){
    for(int i=0;i<3;i++){
    cin>>arr[i];
    }
    sort(arr,arr+3,cmp);
    if(arr[0]+1==arr[1]&&arr[1]+1==arr[2])	cout<<"TRUE";
    else	cout<<"FALSE";
    return 0;
    }
    
    • 0
      @ 2022-12-9 0:58:45

      C :

      #include<stdio.h>   
      
      int main(){ 
      	int a,b,c;
      	scanf("%d %d %d",&a,&b,&c);
      	
      	if(a < b){
      		int t = a;
      		a = b;
      		b = t;
      	}
      	
      	if(b < c){
      		int t = b;
      		b = c;
      		c = t;
      	}
      	
      	if(a < b){
      		int t = a;
      		a = b;
      		b = t;
      	}
      	
      	if(a - b == 1 && b - c == 1){
      		printf("TRUE");
      	}else{
      		printf("FALSE");
      	}
      
      	return 0;
      } 
      

      Python :

      a,b,c = map(int,input().split());
      # a>b>c
      if a < b:
          t=a
          a=b
          b=t 
      if a < c:
          t=a
          a=c
          c=t 
      if b < c:
          t=b
          b=c
          c=t
      if a-b==1 and b-c==1:
          print('TRUE')
      else :
          print('FALSE')
      
      • 1

      【入门】判断三个整数是否相邻

      信息

      ID
      77
      时间
      1000ms
      内存
      16MiB
      难度
      4
      标签
      递交数
      107
      已通过
      49
      上传者