首页 > 其他分享 >LevOJ平台 - 持续更新

LevOJ平台 - 持续更新

时间:2024-10-02 12:49:22浏览次数:1  
标签:main EOF int scanf 平台 更新 printf include LevOJ

LevOJ平台题目可能的解决方法

P1001 a+b的问题

题目描述

解决方法

#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a + b);
    return 0;
}

P1031 三角形的面积

题目描述

解决方法

#include <stdio.h>
#include <math.h>

int main()
{
    double a, b, c, s, area;
    while (scanf("%lf %lf %lf", &a, &b, &c) != EOF)
    {
        if ((a + b > c) && (a + c > b) && (b + c > a))
        {
            s = (a + b + c) / 2.0;

            area = sqrt(s * (s - a) * (s - b) * (s - c));

            printf("%.2f\n", area);
        }
        else
        {
            printf("-1\n");
        }
    }

    return 0;
}

P1048 商和余数

问题描述

解决方法

#include <stdio.h>

int main()
{
    int a, b, c, d;
    while (scanf("%d%d", &a, &b) != EOF)
    {
        c = a / b;
        d = a % b;
        printf("%d %d\n", c, d);
    }

    return 0;
}

P1049 求表达式值

问题描述

解决方法

#include <stdio.h>

int main()
{
    int a;
    float x, y;
    while (scanf("%d %f %f", &a, &x, &y) != EOF)
    {
        float result = x + a % 3 * (int)(x + y) % 2 / 4;
        printf("%.6f\n", result);
    }

    return 0;
}

P1515 判断两个数的大小关系

问题描述

解决方法

#include <stdio.h>

int main()
{
    int x, y;
    while (scanf("%d %d", &x, &y) != EOF)
    {
        if (x == y)
        {
            printf("x==y\n");
        }
        else if (x > y)
        {
            printf("x>y\n");
        }
        else
        {
            printf("x<y\n");
        }
    }

    return 0;
}

P1516 判断三角形的形状

问题描述

解决方法

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n); 

    for (int i = 0; i < n; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c); 

        if (a + b <= c || a + c <= b || b + c <= a) {
            printf("Not Triangle\n");
        } 
        else if (a == b && b == c) {
            printf("Regular Triangle\n");
        } 
        else if (a == b || a == c || b == c) {
            printf("Isosceles Triangle\n");
        } 
        else {
            printf("Triangle\n");
        }
    }

    return 0;
}

P1991 新BMI公式

问题描述

解决方法

#include <stdio.h>

int main()
{
    float n, L;
    while (scanf("%f %f", &n, &L) != EOF)
    {
        float bmi = n / (L * L);
        printf("%.1f\n", bmi);
        if (bmi > 25)
            printf("PANG\n");
        else
            printf("Hai Xing\n");
    }
    return 0;
}

P2069 计算摄氏温度

问题描述

解决方法

#include <stdio.h>

int main()
{
    float f, c;
    while (scanf("%f", &f) != EOF)
    {
        c = 5 * (f - 32) / 9.0;

        printf("Celsius = %.0f\n", c);
    }
    return 0;
}

P2070 比较大小

问题描述

解决方法

#include <stdio.h>
int main()
{
    int a, b, c, t;
    while (scanf("%d %d %d", &a, &b, &c) != EOF)
    {
        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;
        }
        printf("%d->%d->%d\n", a, b, c);
    }
    return 0;
}

P1035 鸡兔同笼问题

问题描述

解决方法

标签:main,EOF,int,scanf,平台,更新,printf,include,LevOJ
From: https://www.cnblogs.com/churk/p/18444573

相关文章