1 solutions

  • 0
    @ 2025-3-3 16:28:35

    C :

    #include<stdio.h>
    int main()
    {
        int x;
        scanf("%d",&x);
        if(x<=10)
            printf("%.1lf",2.0*x);
        if(x>10)
            printf("%.1lf",1.8*x);
            return 0;
    }
    

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	double q;
    	int n;
    	cin>>n;
    	if(n<=10)q=n*2;
    	else q=n*2*0.9;
    	cout<<fixed<<setprecision(1)<<q<<endl;
    	return 0;
    }
    
    

    Java :

    import java.util.Scanner;
    
    public class Main {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		Scanner sc = new Scanner(System.in);
    		int n = sc.nextInt();
    		double s;
    		if(n <= 10){
    			s = 2 * n;
    			System.out.println(String.format("%.1f", s));
    		}else if(n > 10){
    			s = 2 * n * 0.9;
    			System.out.println(String.format("%.1f", s));
    		}
    		sc.close();
    	}
    
    }
    

    Python :

    n = int(input())
    if n > 10:
        m = n * 2 * 0.9
    else:
        m = n * 2
    print('%.1f' % m)
    
    
    • 1

    Information

    ID
    10231
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By