1 条题解
-
0
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; }C++ :
#include<iostream> using namespace std; int main(){ int a,b,c,t; cin>>a>>b>>c; if(a>b){ t=a; a=b; b=t; } if(b>c){ t=b; b=c; c=t; } if(a>b){ t=a; a=b; b=c; } if(c-1==b&&b-1==a){ cout<<"TRUE"<<endl; }else{ cout<<"FALSE"<<endl; } }Pascal :
var a,b,c,t:longint; begin read(a,b,c); if a<b then begin t:=a;a:=b;b:=t; end; if b<c then begin t:=b;b:=c;c:=t; end; if a<b then begin t:=a;a:=b;b:=t; end; if (a-1=b)and(b-1=c)and(c+2=a) then writeln('TRUE') else writeln('FALSE'); end.Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { @SuppressWarnings("resource") Scanner scanner=new Scanner(System.in); int x=scanner.nextInt(); int y=scanner.nextInt(); int z=scanner.nextInt(); if (((2*x==y+z)&&(x-y==1||x-z==1))||((2*y==x+z)&&(y-x==1||y-z==1))||((2*z==y+x)&&(z-y==1||z-x==1))) System.out.print("TRUE"); else System.out.print("FALSE"); } }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
- 40
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者