zzulioj1011-1050

因为整理起来比较慢,如果喜欢java或python的人想要代码的话,请私信我或者评论区留言。

这都是大一上学期写的代码比较稚嫩,如果想要看哪一个题目的分析或者不会做的,可以私信我,或者评论都行,如果再刷zzulioj觉得下面代码有用的话,点个赞关注一下呗。

这些都是最基本的题目,也不会在这个oj做题了,整理的原因是因为想要帮助有需要的人,同时记录一下不成熟的自己。

题目如果存在缺失,私信或者评论。必回。

ZZULI—刷题之路

zzulioj_1000-1010

zzulioj_1011-1050

zzulioj_1101-1110

目录

圆柱体表面积

求绝对值

求两点间距离

求三角形的面积

计算时间间隔

银行利率

判断正整数位数

奇数偶数

公园门票

两整数排序

三个整数的最大值

三整数排序

大小写转换

计算字母序号

最大字符

字符类型判断

判断水仙花数

I love 闰年!

三角形判定

判断直角三角形

判断点在第几象限

员工薪水

五级制成绩

夏季促销

分段函数求值

某年某月有多少天

绝对值最大

n个数求和

数列求和2

数列求和3

不及格率

数值统计

奇数的乘积

对数表

阶乘表

平方和与立方和

阶乘的累加和



圆柱体表面积

#include <stdio.h>

#define PI 3.14159
int main (void )
{
    double r,h;
    scanf("%lf%lf", &r , &h);
    printf("%.2f\n", 2*PI*r*r + 2*PI*r*h);
    return 0;

}

求绝对值

#include <stdio.h>

#include<math.h>
int main()
{
    double a, b;
    scanf("%lf",&a);
    b = fabs(a);
    printf("%.2f\n",b);
    return 0;
}

求两点间距离

#include <stdio.h>

#include<math.h>
int main()
{
    double a, b, c, d;
    scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
    printf("%.2f\n",sqrt((a - c)*(a - c)+(b - d)*(b - d)));
    return 0;
}

求三角形的面积

#include <stdio.h>

#include<math.h>
int main()
{
    double a, b, c, r;
    scanf("%lf%lf%lf", &a, &b, &c);
    r = (a + b + c)/2;
    printf("%.2f\n",sqrt(r*(r - a)*(r - b)*(r - c)));
    return 0;
}

计算时间间隔

#include <stdio.h>

#include<math.h>
int main(void)
{
    int a, b, c, d, e, f;
    scanf("%d:%d:%d\n", &a, &b, &c);
    scanf("%d:%d:%d", &d, &e, &f);
    printf("%d",(d - a)*3600 + (e - b)*60+(f-c)*1);
    return 0;
}

银行利率

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

int main()
{

    double a, b, z, c=1.0225;
    scanf("%lf%lf", &a, &b);
    z=pow(c,a);
    z=z*b;
    printf("%f\n", z);
    return 0;
}

判断正整数位数

#include<stdio.h>

int main ()
{
    int n, i = 0;
    scanf("%d", &n);
    while (n > 0)
    {
        n = n / 10;
        i++;
    }
    printf("%d", i);
    return 0;
}

奇数偶数

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

int main()
{
    int n;
    scanf("%d",&n);
    if(n%2==0)
    {
        printf("even\n");

    }
    else
    {
        printf("odd");
    }
    return 0;
}

公园门票

#include <stdio.h>

int main()
{
    int a;
    scanf("%d",&a);
    if(a>=30)
    {
        printf("%d\n", a*48);

    }
    else
    {
        printf("%d\n", a*50);
    }
    return 0;
}

两整数排序

#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d%d",&a, &b);
    if(a<b)
    {
        printf("%d %d\n", a, b);

    }
    else
    {
        printf("%d %d\n", b, a);
    }
    return 0;
}

三个整数的最大值

#include <stdio.h>

int main()
{
    int a, b, c, max;
    scanf("%d%d%d",&a, &b, &c);
    max =(a > b) ? a : b;
    max =(max > c) ? max : c;
    printf("%d", max);
    return 0;
}

三整数排序

#include "stdio.h"
int main()
{
    int x,y,z,t;
    scanf("%d%d%d", &x, &y, &z);
    if (x < y)
    {
        t = x;
        x = y;
        y = t;
    }
    if(x < z)
    {
        t = x;
        x = z;
        z = t;
    }
    if (y < z)
    {
        t = y;
        y = z;
        z = t;
    }
    printf("%d %d %d", x, y, z);
    return 0;
}

大小写转换

#include <stdio.h>

int main()
{
    char ch;
    ch = getchar();
    if(ch>='a' && ch<='z')
    {
        ch-=32;
        printf("%c\n", ch);
    }
    else
    {
        printf("%c\n", ch);
    }

    return 0;
}

计算字母序号

#include <stdio.h>

int main()
{
    char ch;
    ch = getchar();
    if(ch>='A' && ch<='Z')
    {
        ch+=32;
    }
    ch = ch - 96;
    printf("%d\n", ch);

    return 0;
}

最大字符

#include "stdio.h"
int main()
{
    char x,y,z,t;
    scanf("%c %c %c", &x, &y, &z);
    t = x;
    if (t < y)
    {
        t = y;
    }
    if (t < z)
    {
        t = z;
    }
    printf("%c", t);
    return 0;
}

字符类型判断

#include <stdio.h>

int main()
{
    char ch;
    ch = getchar();
    if(ch >= 'a' && ch <= 'z')
    {
        printf("lower");
    }
    else
    {
        if(ch >= 'A' &&  ch <= 'Z')
        {
            printf("upper");

        }
        else
        {
            if(ch >= '0' && ch <= '9')
            {
                printf("digit");
            }
            else
            {
                printf("other");
            }

        }
    }

    return 0;
}

判断水仙花数

#include "stdio.h"
int main()
{
    int n, a, b, c, m;
    scanf("%d", &n);
    m = n;
    a = n % 10;
    n = n /10;
    b = n % 10;
    n = n /10;
    c = n % 10;
    if ((a*a*a + b*b*b +c*c*c ) == m)
        printf("yes");
    else
        printf("no");
    return 0;
}

I love 闰年!

#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);

    if ((n % 400 == 0 ) || ((n % 4 == 0)&&( n % 100 != 0)))
        printf("Yes");
    else
        printf("No");
    return 0;
}

三角形判定

#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(((a + b) > c) && ((b + c) > a) && ((a + c) > b))
        printf("Yes");
    else
        printf("No");

    return 0;
}

判断直角三角形

#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(((a*a + b*b) == c*c) || ((b*b+ c*c) == a*a))
        printf("yes");
    else
    {
        if( (a*a + c*c) == b*b)
            printf("yes");
        else
            printf("no");
    }

    return 0;
}

判断点在第几象限

#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if((a > 0) && (b > 0))
        printf("1");
    else if((a>0) && (b < 0))
        printf("4");
    else if((a < 0) && (b > 0))
        printf("2");
    else if((a < 0) && (b < 0))
        printf("3");
    return 0;
}

员工薪水

#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d", &a);
    if(a <= 10000)
    {
        b = 1500 + 0.05*a;
        printf("%.2f", 1.00 * b);
    }
    else
    {
        if(a > 10000 && a <= 50000)
        {
            b = 1500 + 10000 * 0.05 + (a - 10000) * 0.03;
            printf("%.2f", 1.00 * b);
        }
        else
        {
            b = 1500 + 10000 * 0.05 + 40000 * 0.03 + (a - 50000) * 0.02;
            printf("%.2f", 1.00 * b);
        }
    }
    return 0;
}

五级制成绩

#include <stdio.h>
int main()
{
    int n;
    char m;
    scanf("%d", &n);

    if ( n >= 90)
        m = 'A';
    else if (( n>=80)&& (n <= 89))
        m= 'B';
    else if((n >= 70)&&(n <= 79))
        m = 'C';
    else if((n <= 69)&&( n >= 60))
        m = 'D';
    else
        m ='E';
    printf("%c", m);

    return 0;
}

夏季促销

#include <stdio.h>

int main(void)
{
    int a;
    double b;
    scanf("%d", &a);
    a = 1.0 * a;
    if(a < 500)
    {
        b = a;
        printf("%.2f", b);
    }

    if(a >= 500 && a < 1000)
    {
        b = a * 0.95;
        printf("%.2f", b);
    }
    if(a >= 1000 && a < 3000)
    {
        b = a * 0.9;
        printf("%.2f", b);
    }


    if(a >= 3000 && a< 5000)
    {
        b = a * 0.85;
        printf("%.2f", b);
    }

    if(a >= 5000)
    {
        b = a * 0.8;
        printf("%.2f", b);

    }


    return 0;
}

分段函数求值

#include <stdio.h>
#include<math.h>
int main ()

{
    int a, b, c;
    scanf("%d", &a);

    if(a < -2)
    {
        b = 7 - 2 * a;
        printf("%d", b);
    }
    else
    {
        if(a >= 3)
        {
            b = 3 * a + 4;
            printf("%d", b);

        }
        else
        {
            c = 3 * a + 2;
            c = fabs(c);
            b = 5 - c;
            printf("%d", b);
        }
    }
    return 0;

}

某年某月有多少天

#include<stdio.h>

int main ()
{
	int year, month, days;

	scanf("%d %d", &year, &month);

	switch(month)
	{
	case 4:
	case 6:
	case 9:
	case 11: days = 30; break;
	case 2:
		if((year%400 == 0)||(year%4 == 0 && year%100 != 0))
			days = 29;
		else
			days = 28;
		break;
	default: days = 31;
	}

	printf("%d\n",days);
	return 0;
}

绝对值最大

#include<stdio.h>

#include<math.h>
int main()
{
    int a, b, c, max;
    scanf("%d%d%d", &a, &b, &c);
    max = a;
    if( abs(max) < abs(b))
        max = b;
    if( abs(c) > abs(max))
        max = c;
    printf("%d", max);

    return 0;
}

n个数求和

#include<stdio.h>

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

    sum = 0;

    for(i = 1;i <= n; i++)
    {
        scanf("%d", &b);
        sum =  sum + b;
    }
    printf("%d", sum);
    return 0;
}

数列求和2

#include<stdio.h>

#include<math.h>
int main ()
{
    int n, i;
    double sum, b, c;
    scanf("%d", &n);
    for(i =0;i <= (n - 1) ; i++)
    {
        b = 1.0 * i;
        c = pow(-1,b);

        sum = sum + c * 1 /(2 * b +1);

    }
    printf("%.2f", sum);
    return 0;
}

数列求和3

#include<stdio.h>

#include<math.h>
int main ()
{
    int n, i, q;
    double sum, b, c;
    scanf("%d", &n);
    q = 1;
    for(i =0;i <= (n - 1) ; i++)
    {
        b = 1.0 * i;
        c = pow(-1,b);

        sum = sum + c * q /(2 * b +1);
        q = q + 1;


    }
    printf("%.3f", sum);
    return 0;
}

不及格率

#include<stdio.h>

int main ()
{
    int n, i, q, b;
    double a;
        scanf("%d", &n);
        b = 0;

        for(i = 1; i <= n; i++)
        {
            scanf("%d", &q);
            if (q < 60)
            b++;

        }
        a = 1.0 * b / (n * 1.0);
    printf("%.2f", a);
    return 0;
}

数值统计

v#include<stdio.h>

int main ()
{
    int a, b, c, n, i, q;
    scanf("%d", &n);
    a = 0;
    b = 0;
    c = 0;

    for(i = 1; i <= n; i++)
    {
        scanf("%d", &q);
            if (q < 0)
            {
                a++;
            }
            else
            {
                if(q > 0)
                {
                    c++;
                }
                else
                {
                    b++;
                }
            }


    }
    printf("%d %d %d", a, b, c);
    return 0;
}

奇数的乘积

#include<stdio.h>

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

        scanf("%d", &a);
        if (a % 2 != 0)
        {
            a = b * a;
            b = a;
        }
    }
    printf("%d", b);
    return 0;
}

对数表

#include<stdio.h>

#include<math.h>
int main ()
{
    int a, b;
    double y;
    scanf("%d%d", &a, &b);
    for( a = a; a <= b; )
    {
        y = log(a);
        printf("%4d%8.4f\n", a, y);
        a = a + 1;
    }
    return 0;
}

阶乘表

#include<stdio.h>

int main ()
{
    double n, i, a;
    double b, y=1;
    scanf("%lf", &n);
    for (i = 1; i <= n; i++)
    {
        for(a=1; a <= i;a++)
        {
            b = a ;

        }
        y = b * y;
        printf("%-4.0f%-20.0f\n", i, y);

    }
    return 0;
}

平方和与立方和

#include<stdio.h>

int main ()
{
    int m, n, a;
    int b, y=0, x=0;
    scanf("%d%d",&m, &n);
    for(m = m; m <= n;m++)
    {
        if(m % 2 == 0)
        {
            b = m * m;
            y = b + y;
        }
        else
        {
            a = m * m *m;
            x = x + a;
        }
    }
    printf("%d %d", y, x);
    return 0;
}

阶乘的累加和

#include<stdio.h>

int main ()
{
    int n, i;
    int x=1, y = 0;
    scanf("%d",&n);
    for(i=1; i <= n;i++)
    {
        x = x * i;
        y = y + x;
    }
    printf("%d", y);
    return 0;
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZZULI_星.夜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值