zoukankan      html  css  js  c++  java
  • ZOJ Problem Set

    这道题目还是简单的,但是自己WA了好几次,总结下:

    1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结

    题目要求输入的格式:

    START

    X Y Z

    END

    这算做一个data set,这样反复,直到遇到ENDINPUT。我们可以先吸纳一个字符串判断其是否为ENDINPUT,若不是进入,获得XYZ后,吸纳END,再进行输出结果

    2.注意题目是一个圆周,所以始终用锐角进行计算,即z=360-z;

    3.知识点的误区:浮点数截断

    double data;

    printf("%d",int(data));             //强制类型转换后输出

    printf("%.0lf",data);                //直接舍弃小数位

    这两个是不一样的,为什么暂不知,在论坛提问中。。。

    #include <stdio.h>
    #include <math.h>
    #include <string.h>
    
    #define pi 3.14159
    
    int main()
    {
        char str[10];
    
        while(scanf("%s",str)!=EOF&&strcmp(str,"ENDOFINPUT"))
        {        
            int x,y,z;
            double dis,gal;
            
            scanf("%d%d%d",&x,&y,&z);
            if(z>180)
                z=360-z;
            dis=2*pi*x*(double(z)/360.0)*2;
            gal=y*5.0;
            scanf("%s",str);                    //把END吸收掉
            if(dis<=gal)
            {
                printf("YES %d
    ",int((gal-dis)/5.0));
            }
            else
            {
                printf("NO %d
    ",(int)gal);
            }
    
        }
    
        return 0;
    }
  • 相关阅读:
    vue 插件的使用 todolist案例
    vue 传值 混入mixin
    vue 生命周期函数
    vue 指令总结
    vue 其它的指令
    vue 监听数据变化的原理 表单数据的收集
    vue for循环中的key
    vue 学习
    vue 学习
    HDU 1029
  • 原文地址:https://www.cnblogs.com/xlturing/p/3369632.html
Copyright © 2011-2022 走看看