1 条题解

  • 0
    @ 2026-8-5 2:25:41

    C :

    #include <stdio.h>
    double a, b;
    int main(void) {
        scanf("%lf %lf", &a, &b);
        if (a > 0 && b > 0) {
            printf("%.2f %.2f", a * b, 2.0 * (a + b));
        } else {
            printf("error");
        }
        printf("\n");
        return 0;
    }
    

    C++ :

    #include<iostream>
    
    #include<cstdio>
    
    using namespace std;
    
    int main()
    {
        double a,b;
        cin>>a>>b;
        if (a>0&&b>0)
        printf("%.2lf %.2lf",a*b,(a+b)*2);
    else
        cout<<"error"<<endl;
        return 0;
    }
    

    Python :

    # coding=utf-8
    s = input(). split()
    a, b = float(s[0]), float(s[1])
    if a > 0 and b > 0 :
        print(format(a * b, ".2f"), format(2 * (a + b), ".2f"))
    else :
        print("error")
    
    
    • 1

    信息

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