小编kev*_*sa5的帖子

处理'看起来你正在混合"主动"和"静态"模式.

当我运行它时,处理仍然给我这个错误,即使它只是一个打印命令.当我删除评论块时,它工作正常.这是代码:

/*
    float[] cortToPolar(int xcorr, int ycorr) {
    float returns[] = new float[2];
    returns[0]= degrees(tan(ycorr/xcorr));
    returns[1]= sqrt(pow(xcorr,2)+pow(ycorr,2));
    return returns;
}

float lawCos(int a, int b, int c) {
  return degrees(
     acos(
     (pow(a,2)+pow(b,2)-pow(c,2))/
       (2*a*b)
     )
  );
}
*/
print(0); 
Run Code Online (Sandbox Code Playgroud)

为什么它不喜欢我的评论?

processing comments

14
推荐指数
1
解决办法
4万
查看次数

为什么这些没有 TLD 的 URL 会解析为网页?

我注意到 URL ga 解析为一个网站,但没有 .com、.org 等 TLD。我编写了一个脚本来测试所有两个字母的 URL:

#!/bin/bash
for a in {a..z}
do
    for b in {a..z}
    do
        curl "$a$b" -s -m 10 >> foo.txt
        if [ -s foo.txt ]
        then
            cp foo.txt "$a$b.txt"
            rm foo.txt
            echo "$a$b"
        fi
    done
done
Run Code Online (Sandbox Code Playgroud)

打印

ai
dk
pn
to
uz
Run Code Online (Sandbox Code Playgroud)

该脚本并不完美(例如,它无法识别ga),但它显示还有更多这样的 URL。我确实注意到这些 URL 本身都是 TLD——ai 是安圭拉,dk 是丹麦,等等。为什么这些 URL 在解析为 IP 地址的意义上是“有效的”,以及为什么它们存在?

(我会将它们制作成可点击的链接,但有趣的是,SO 格式化程序不会接受它们为有效。)

url tld

9
推荐指数
1
解决办法
3919
查看次数

从带有Gif动画库的Processing sketch导出gif

我想将我的一个Processing草图导出为gif格式,并使用extrapixel的Gif动画库(http://extrapixel.github.io/gif-animation/)来实现.

我能够导出正确数量的帧,但它们都显示为空.
任何想法为什么会这样?

import gifAnimation.*;

GifMaker gifExport;

float angle = 0.1;

void setup() {
  size(500, 500);
  smooth();
  noStroke();
  background(0);

  frameRate(12);
  gifExport = new GifMaker(this, "spin rect sine growth.gif");
  gifExport.setRepeat(0); // make it an "endless" animation
  gifExport.setTransparent(255); // make white the transparent color -- match browser bg color
}

void draw() {

  float size = map(sin(angle),-1,1,0,height);
  rectMode(CENTER);
  translate(width/2, height/2);
  rotate(angle);
  noStroke();
  fill(255,255);
  rect(0,0, size, size);
  angle += 0.0523 ;

  noStroke();
  fill( 0, 15);
  rect(0, 0, width, height);

  gifExport.setDelay(0);  //maybe …
Run Code Online (Sandbox Code Playgroud)

processing animation export gif

7
推荐指数
1
解决办法
1万
查看次数

2个明显相同的代码!一个编译,一个抛出seg错误

我是一个初学的C程序员,只是编写一个涉及队列操作的练习题,在调试时,我遇到了以下场景:

代码示例1:

int dequeue (struct queue_node * Q) {

    struct queue_node * curr = Q->next;
    if(!Q->next)
            return -2;
    else
    {
            int s = Q->next->v_no;
            Q->next = curr->next;
            free(curr);
            return s;
    }

}
Run Code Online (Sandbox Code Playgroud)

代码示例2(以稍微修改的方式编写的相同函数):

int dequeue (struct queue_node * Q) {

    struct queue_node * curr = Q;
    if(!curr->next)
            return -2;
    else
    {
            int s = curr->next->v_no;
            Q->next = curr->next->next;
            free(curr->next);
            return s;
    }

}
Run Code Online (Sandbox Code Playgroud)

预定义的数据结构如下:

struct queue_node {

    int v_no;
    struct queue_node * next;

};

void enqueue (struct queue_node …
Run Code Online (Sandbox Code Playgroud)

c queue struct

3
推荐指数
1
解决办法
128
查看次数

标签 统计

processing ×2

animation ×1

c ×1

comments ×1

export ×1

gif ×1

queue ×1

struct ×1

tld ×1

url ×1