打码真累w

嗯,还好只是给静态图像打码,要是给视频打码的话……那个渲染……orz
话虽如此,上百张的图片打码也一样累死啊((((;゚Д゚)))

话说这次C语言编程入门的课的作业是找出20对“相亲数”,于是因为要球约数所以为了节约球约数的时间准备只查到这个数的平方根为止就不查了,而如果这个数是平方数的话开平方根的结果是整数并且自然这个数本身也就是约数之一了——于是问题来了:C语言怎么判断那个是整数啊orz

偶这里用的办法是:
int x=数值;
int sqx=sqrt(x);
if (sqx == sqrt(x)){
printf ("平方根是整数");
}

这样的方法w 8过同学表示说因为开平方根之后很大的可能是实数而非整数所以强制使用int宣言sqx不好,而且Windows上Visual Studio也会出现报警(8过报警归报警,编译还是可以的);但是Mac上使用Xcode写这样的代码就完全不会告诉偶有任何问题,当然编译下来运行也完全没有任何问题就是了ww
于是这里继续球其他的判断平方根是否是整数的方法w

Author: 星野恵瑠

Mac user, Niji-Ota, Chinese, Now working in Japan at MAGES. Inc., Future's aim is that one day my name can be listed in Wikipedia

25 thoughts on “打码真累w”

  1. 马赛克,阻碍人类进步的最大障碍⋯⋯
    有时候看不见反而更让人浮想联翩⋯⋯
    于是从第三行开始又看不懂了⋯⋯

  2. 上班不能想太久,在你的方案的基础上修改了一下:

    //x为整数
    int x=数值;

    //将平方根后的结果切捨て
    //sqrt的返回值为double型,floor的引数和结果也都是dobule型
    double sqx = floor(sqrt(x));

    //两者的差为0时,为整数。
    if (sqx – sqrt(x) = 0){
    printf (“平方根是整数”);
    }

  3. 刚才的有处错误,修改后:
    //x为整数
    int x=数值;
    //将平方根后的结果切捨て
    //sqrt的返回值为double型,floor的引数和结果也都是dobule型
    double sqx = floor(sqrt(x));
    //两者的差为0时,为整数。
    if (sqx – sqrt(x) == 0){
    printf (“平方根是整数”);
    }

  4. @Maid:
    女仆酱抱抱 (;;)

    @conanshang:
    没找到“专门打码”的工具呢 (-w-;)

    @Bill gates hxk:
    就是因为找过了没找到看得懂的才问的 (……)

    @looseboy:
    感谢 (:D) 虽然考虑到实际使用场景而把floor改成了ceil,而且最后因为有一个计算必须要用到int所以将ceil的double结果强制加到int的函数里面还是会警告,嘛不管他了

    @夜夜無夢:
    偶已经想杀了那个规定关键部位要打码的人了 (==)

  5. @Lovee:
    呜…昨晚想玩Little Busters的时候,把UMD放到PSP中,发现读不出来了,电机貌似坏掉了… (TAT)
    PSP这东西国内没行货,修起来肯定都是奸商 (-w-;)

  6. 话说打码是神马?是水印么?水印的话偶是用PIL批量打码的。
    话说这么判断的话相当于执行了2次sqrt(x),个人觉得不如直接将sqrt赋值给一个float,然后直接cast或者用floor或者cell来作判断。不过其实小段代码不会产生什么效率问题就是了~~

  7. 贴关键代码吧~ double a;
    scanf(“%lf”,&a);
    printf(“%lf\n”,a);
    if(int(a)==a)
    printf(“Yes\n”);
    else
    printf(“No\n”);

  8. @灵曦:
    #include
    int main(void)
    {
    double a;
    int b;
    scanf(“%lf”,&a);
    if(int(a)==a)
    {b=a;
    printf(“%d\n”,b);
    }//you can do MOD here
    else
    printf(“not integer”);
    //break
    return 0;
    }

  9. @灵曦:
    嘛管得它的warning就warning了反正能compile就行了 ( ̄‥ ̄)
    8过话说偶在Xcode上直接写int = double的代码的时候完全没有任何警告直接compile过去了 (;;) 果然Mac环境更宽松么

  10. @Lovee:
    没在xcode写过呢,弱类型语言嘛?不清楚呢。。有的语言确实不会报错,比如PHP…弱得不能再弱了。。(学C再看PHP你PHP简直就是个受!)
    灵曦睡觉去了~~

Leave a Reply to winw Cancel reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

(;;) (:D) (!!!!) (……) (^o^;) (==) (OoO) (=v=o) more »Note: Commenter is allowed to use '@User+blank' to automatically notify your reply to other commenter. e.g, if ABC is one of commenter of this post, then write '@ABC '(exclude ') will automatically send your comment to ABC. Using '@all ' to notify all previous commenters. Be sure that the value of User should exactly match with commenter's name (case sensitive).