1 条题解

  • 0
    @ 2023-6-11 12:20:43

    C :

    #include<stdio.h>
    main() {
    	int x,y,z;
    	scanf("%d %d %d %d",&x,&y,&z);
    	double a = (x + y + z) / 3.0;
    	if(a >= 90) {
    		int n = 0;  //统计在90分以上的科目数量
    		if(x >= 90) {
    			n++;
    		}
    		if(y >= 90) {
    			n++;
    		}
    		if(z >= 90) {
    			n++;
    		}
    		if(n == 3) {
    			printf("beijing");
    		} else if(n == 2) {
    			printf("xiamen");
    		} else {
    			printf("guilin");
    		}
    	} else if(a >= 85) {
    		if(x >= 85 && y >= 85 && z >= 85) {
    			printf("shanghai");
    		}  else {
    			printf("nanjing");
    		}
    	}
    }
    
    

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int x,y,z,c = 0;
        cin>>x>>y>>z;
        double v = (x + y + z) / 3.0;
        if(v >= 90){
        	if(x >= 90) c++;
    		if(y >= 90) c++;
    		if(z >= 90) c++;
    		
    		if(c == 3) cout<<"beijing";
    		else if(c == 2) cout<<"xiamen";
    		else cout<<"guilin";
    	}else if(v >= 85){
    		if(x >= 85) c++;
    		if(y >= 85) c++;
    		if(z >= 85) c++;
    		
    		if(c == 3) cout<<"shanghai";
    		else cout<<"nanjing";
    	}
    }
    

    Java :

    import java.util.Scanner;
    public class Main
    {
    	public static void main(String[] Args)
    	{
    		Scanner sc = new Scanner(System.in);
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		int c = sc.nextInt();
    		int d = (a+b+c)/3;
    		int i = 0;
    		int j = 0;
    		if(a>=90) ++i;
    		else if(a>=85) ++j;
    		if(b>=90) ++i;
    		else if(b>=85) ++j;
    		if(c>=90) ++i;
    		else if(c>=85) ++j;
    		if(d>=90){
    
    			if(i == 3) System.out.println("beijing");
    			if(i == 2) System.out.println("xiamen");
    			if(i == 1) System.out.println("guilin");
    		}
    		else if(d>=85){
    			if(j == 3) System.out.println("shanghai");
    			else System.out.println("nanjing");
    		}
    
    	}
    }
    

    Python :

    # 输入字符串切割
    s = input().split()
    x = int(s[0])
    y = int(s[1])
    z = int(s[2])
    # 平均分v
    v = (x + y + z) / 3
    # 判断是远途还是周边
    if v >= 90:   #远途
        if x >= 90 and y >= 90 and z >= 90:
            print("beijing")
        elif (x >= 90 and y >= 90) or (x >= 90 and z >= 90) or (y >= 90 and z >= 90):
            print("xiamen")
        else:
            print("guilin")
    elif 85 <= v < 90:   #周边
        if x>=85 and y>=85 and z>=85:
            print("shanghai")
        else:
            print("nanjing")
    
    • 1

    信息

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